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); } ?> Quote Link to comment 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'); Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
barnes Posted April 25, 2007 Author Share Posted April 25, 2007 thank you bthrel Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.