Jump to content

Recommended Posts

My code looks like this :

[code]$sql3 = mysql_query("INSERT INTO $list1 (user_id, fullname) VALUES ('$userid', '$name')") or die (mysql_error());[/code]

However, it does not work and I get the following 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 '(user_id, fullname) VALUES ('1121', 'Jeff Gordon')'

can anyone tell me what I'm doing wrong. Any help would be greatly appreciated. Thanks
Link to comment
https://forums.phpfreaks.com/topic/10031-using-variables-for-table-names-sql/
Share on other sites

[!--quoteo(post=375327:date=May 19 2006, 04:09 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 19 2006, 04:09 PM) [snapback]375327[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
$sql3 = mysql_query("INSERT INTO '$list1' (user_id, fullname) VALUES ('$userid', '$name')") or die (mysql_error());
[/code]
try putting quotes around $list1
[/quote]

I already tried that. I get this 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 ''' (user_id, fullname) VALUES ('1121', 'Jeff Gordon')'

thanks tho
echo $list1;

see if it is holding the correct table name (including spelling).

then also make sure that user_id and fullname are the correct column names (including spelling), and also they correct data types for what you are trying to insert. user_id should at least be an int and fullname should at least be a varchar
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.