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()); Quote 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? Quote 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 ''unholyprayer@mutant-designs.com''' at line 1 even after i put spaces in the places you said. Quote 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' Quote 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 Quote 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()); Quote 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 Quote 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()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/44188-mysql_query-insert/#findComment-214609 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.