Unholy Prayer Posted March 25, 2007 Share Posted March 25, 2007 My database insertion code isn't working and I can't figure out why. This is the code: mysql_query("INSERT INTO vbb_members(username,password,email,reg_date,mem_no,perm) values('$username', '$password', '$email', '$reg_date', '$mem_no', '$perm')") or die("Error: ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/ Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 put a space after vbb_members and values ... it shouldn't really matter but try anyways, is it giving you an error, or just not inserting? Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214586 Share on other sites More sharing options...
Unholy Prayer Posted March 25, 2007 Author Share Posted March 25, 2007 It's displaying an error: Error: 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 ''[email protected]''' at line 1 even after i put spaces in the places you said. Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214588 Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 o, try this: \"$email\" instead of '$email' Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214590 Share on other sites More sharing options...
Unholy Prayer Posted March 25, 2007 Author Share Posted March 25, 2007 Now it's saying Error: 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 ''Test' at line 1 Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214592 Share on other sites More sharing options...
cmgmyr Posted March 25, 2007 Share Posted March 25, 2007 try: mysql_query("INSERT INTO vbb_members (username,password,email,reg_date,mem_no,perm) values (\"$username\", \"$password\", \"$email\", \"$reg_date\", \"$mem_no\", \"$perm\")") or die("Error: ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214596 Share on other sites More sharing options...
kenrbnsn Posted March 25, 2007 Share Posted March 25, 2007 Change you code to: <?php $q = "INSERT INTO vbb_members(username,password,email,reg_date,mem_no,perm) values('$username', '$password', '$email', '$reg_date', '$mem_no', '$perm'); $rs = mysql_query($q) or die ("Error in query:<pre>$q</pre><br>".mysql_error()); ?> This will display what the generated query looks like. If you don't see the error in the query, post it here. Ken Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214598 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Share Posted March 25, 2007 Correction kenrbnsn missed a " <?php $q = "INSERT INTO vbb_members(username,password,email,reg_date,mem_no,perm) values('$username', '$password', '$email', '$reg_date', '$mem_no', '$perm')"; $rs = mysql_query($q) or die ("Error in query:<pre>$q</pre><br>".mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.