barnes Posted April 25, 2007 Share Posted April 25, 2007 please help me.i unable to find the following error in code Parse error: parse error in c:\easyphp1-8\www\insert.php on line 13 my column names in mysql(db_user)(person) firstname lastname age <html> <body> <form name=frmname" method="post" action="insert.php" enctype="multipart/form-data"> <table border="0" wodth=200 height=200 align="center"> <tr><td>Firstname</td><td><input type="text" name="fname"></td></tr><br> <tr><td>Lastname</td><td><input type="text" name="lname"></td></tr><br> <tr><td>age</td><td><input type="text" name="age"></td></tr><br> <tr colspan="2"><td align="center"><input type="submit" value="submit"></td></tr> </table> </body> </html> insert.php <?php $con=mysql_connect("localhost","root",""); if(!$con) { die("connection error:".mysql_error()); } else { mysql_select_db("db_user",$con); $qry="INSERT INTO person(firstname,lastname,age)VALUES('$_POST[fname]','$_POST[lname]','$_POST[age]') if(!mysql_query($qry,$con)); { die("connection error:".mysql_error()); } echo "record is added"; mysql_close($con); } ?> Link to comment https://forums.phpfreaks.com/topic/48582-how-to-fix-this-bug/ Share on other sites More sharing options...
benjaminbeazy Posted April 25, 2007 Share Posted April 25, 2007 you're missing a quote and a semicolon at the end of $qry $qry="INSERT INTO person(firstname,lastname,age)VALUES('$_POST[fname]','$_POST[lname]','$_POST[age]'); if you still have problems, change it to this $first = $_POST['fname']; $last = $_POST['lname']; $age = $_POST['age']; $qry="INSERT INTO person(firstname,lastname,age)VALUES('$first','$last','$age'); Link to comment https://forums.phpfreaks.com/topic/48582-how-to-fix-this-bug/#findComment-237891 Share on other sites More sharing options...
btherl Posted April 25, 2007 Share Posted April 25, 2007 Also, this will not do what you want it to: if(!mysql_query($qry,$con)); { die("connection error:".mysql_error()); } You must remove the ";" at the end of the first line I copied and pasted. Otherwise the die() will execute every time, regardless of if the query succeeds or fails. Link to comment https://forums.phpfreaks.com/topic/48582-how-to-fix-this-bug/#findComment-237903 Share on other sites More sharing options...
barnes Posted April 25, 2007 Author Share Posted April 25, 2007 thank you bthrel Link to comment https://forums.phpfreaks.com/topic/48582-how-to-fix-this-bug/#findComment-237907 Share on other sites More sharing options...
benjaminbeazy Posted April 25, 2007 Share Posted April 25, 2007 thanks for helping btherl, i'm dying here Link to comment https://forums.phpfreaks.com/topic/48582-how-to-fix-this-bug/#findComment-237908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.