Hard Light Productions Forums
Off-Topic Discussion => General Discussion => Topic started by: MatthewPapa on June 22, 2005, 01:26:40 pm
-
Right now I am writing a pilot creation form so that users can create a new PXO pilot to play with. The task invoves inserting like 4 fields of data into an table on a SQL database. This is all done though a HTML form. Here is my code
My HTML form page:
and my php page that takes care of the insertion:
$usr = "myusername";
$pwd = "mypassword";
$db = "fs2openpxo";
$host = "localhost";
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (!$cid) { print "ERROR: " . mysql_error() . "\n"; }
$username = $_POST["username"];
$password = $_POST["password"];
$squadron = $_POST["squadron"];
$email = $_POST["email"];
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$sql = " INSERT INTO useraccounts ";
$sql .= " (UserName, PassWord, Email, Squadron) VALUES ";
$sql .= " ('$username', '$password','$email','$squadron') ";
$result = mysql_query($sql, $cid);
if (mysql_error()) { print "Database ERROR: $sql " . mysql_error(); }
?>
I keep getting a parse error when I try and run this.
An example can be found at http://freespaceserver.cjb.net/fs2netd/newpilot.php
Any help on this is appreciated. Thanks in advance.
EDIT: cant get the HTML to appear as HTML. View page source to see the form's HTML content.
-
Is that the complete source of that file?
Edit: I think (it's been awhile) that you might have to use \' instead of just ' in double-quote strings.
-
All that I have written so far. Do I need more?
-
Well, it's just that there's supposedly a parse error on line 36, but there is no line 36, and according to the source you posted there is no header file :wtf:
Nor is there a or
-
http://freespaceserver.cjb.net/pilot/
browse them as text files there
-
Originally posted by WMCoolmon
Edit: I think (it's been awhile) that you might have to use \' instead of just ' in double-quote strings.
What do u mean?
-
Single quotes inside double quoutes are ok.
There is a missing '}' in the last if-statement.
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$sql = " INSERT INTO useraccounts ";
$sql .= " (UserName, PassWord, Email, Squadron) VALUES ";
$sql .= " ('$username', '$password','$email','$squadron') ";
$result = mysql_query($sql, $cid);
if (mysql_error()) {
print "Database ERROR: $sql " . mysql_error();
}
} //here
-
well, it may have helped. I just updated the code. Still a parse error. Check it out.
http://freespaceserver.cjb.net/fs2netd/newpilot.php
What else could it be?
-
ITS WORKING NOW!
HALLELUYA
all it needed was that } wojta suggested and a ?>
Thanks for hte help guys.
-
Kudos! Registerred.