Joey46 Posted March 5, 2009 Share Posted March 5, 2009 Ikeep getting this same error and i have copied an pasted the same code from other scripts that work fine i have spent hours trying to work this out someone please help me.Thank you in advance (just in case i forget)This is the 1 line of my script that is falling over$sql = "INSERT into Teachers (Teacher_ID, Name, Password, Email ) values ('$Teacher_ID', '$Name','Password', '$Email')"; Link to comment Share on other sites More sharing options...
jlhaslip Posted March 5, 2009 Share Posted March 5, 2009 What error are you getting? Paste the Error here, please.Echo that variables just before that query to see what is in there. Are you trying to enter a duplicate Teacher_IDor email, maybe? Link to comment Share on other sites More sharing options...
Joey46 Posted March 5, 2009 Author Share Posted March 5, 2009 What error are you getting? Paste the Error here, please.Echo that variables just before that query to see what is in there. Are you trying to enter a duplicate Teacher_IDor email, maybe?This is the errorParse error: syntax error, unexpected T_VARIABLE in /home/.baldric/kwilliams1/public_html/ICAA5139A/PHP/studentadd.php on line 32 Link to comment Share on other sites More sharing options...
justsomeguy Posted March 5, 2009 Share Posted March 5, 2009 The line of code you posted doesn't have any errors, you're probably missing a semicolon or something on the previous line. Link to comment Share on other sites More sharing options...
Joey46 Posted March 5, 2009 Author Share Posted March 5, 2009 The line of code you posted doesn't have any errors, you're probably missing a semicolon or something on the previous line.Ok i will re-check all my work Thankyou Link to comment Share on other sites More sharing options...
Joey46 Posted March 5, 2009 Author Share Posted March 5, 2009 The line of code you posted doesn't have any errors, you're probably missing a semicolon or something on the previous line.Ok i found the semicolon that was missing now i am getting this message Not Working!so below is my code as i can not work out why it is not working$ID =$_POST['ID'];$Name =$_POST['name'];$Password =$_POST['password'];$Email =$_POST['email'];$Address =$_POST['address'];$PhoneNumber =$_POST['phonenumber'];$sql = "INSERT into students (ID, Name, Password, Email, Address, PhoneNumber ) values ('$ID', '$Name', '$Password', '$Email', '$Addres', '$PhoneNumber')"; if(mysql_query($sql, $conn)){ echo "<h4> Student Added! </h4>"; } else { echo "<h4> Not Working! </h4>"; } ?> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 5, 2009 Share Posted March 5, 2009 Use mysql_error to get the error message from MySQL.echo mysql_error(); Link to comment Share on other sites More sharing options...
Joey46 Posted March 5, 2009 Author Share Posted March 5, 2009 Use mysql_error to get the error message from MySQL.echo mysql_error();This is the message i am getting back You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') values ('.D', '', '', '',)' at line 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted March 5, 2009 Share Posted March 5, 2009 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') values ('.D', '', '', '',)' at line 1If you print out the entire query, I think you'll find some extra commas. Link to comment Share on other sites More sharing options...
Joey46 Posted March 7, 2009 Author Share Posted March 7, 2009 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') values ('.D', '', '', '',)' at line 1If you print out the entire query, I think you'll find some extra commas.Thank you JustSomeGuy thats working fine now Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.