PHP Form Help

A

Anonymous

Guest
Print the $sqlstatement before you execute it, that should give you a clue. If the firstname, lastname or birthdate contain a ' it will fail...

While debugging, instead of die ("Couldn't execute the SQL statement");, use something more descriptive like:

die ("Couldn't execute the SQL statement<br />" . mysql_error());

You wouldn't want this in a production environment ofcourse, but for debugging it's really good.

Coditor
 
It would be nice to see the form you are using. Like coditor said you need to have a form with the method=POST. FYI, line 34 has the word "table" spelled "tablel". I'm not sure what you named your table, but I suggest that you name your table something descriptive like maybe "master_names" or "name_table". I would also avoid using the $first= $_POST["first"] etc. etc. that leaves you with too many """" in the final insert statement. So your statement on line 34 should be like this...

$sqlstatement = "INSERT INTO master_names (first, last, dob) VALUES ('$_POST[first]', '$_POST[last]', '$_POST[dob]')";
$sql_result = mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL statement");
mysql_close($connection);

Cheers!
Justin
 
Back
Top