Jump to content

Recommended Posts

[code]
$query="UPDATE '$table' SET rating='$new_rating2',votes='$new_count' WHERE jokeID='$jokeID'";
[/code]

I can't get it to update my database correctly when I run mysql_query($query);
When I attempt to substitute the variable names and run the mysql command on the database it says incorrect syntax.
Link to comment
https://forums.phpfreaks.com/topic/32119-is-this-wrong/
Share on other sites

single quotes around the [b]'[/b]$table[b]'[/b] name is wrong. Backtick's, (back quote), [b]`[/b] should be used if your using a database reserved word for a column or table name. Otherwise it's senseless to use them. Most people who use them everywhere use them because they see others use them.

printf
Link to comment
https://forums.phpfreaks.com/topic/32119-is-this-wrong/#findComment-149073
Share on other sites

You only use apostrophes (') when dealing with values for columns not when dealing with column/table names. You should use back ticks for those (`). Backticks should only be used when you have a column/table name that has the same name as a reserved keyword.
Link to comment
https://forums.phpfreaks.com/topic/32119-is-this-wrong/#findComment-149294
Share on other sites

[quote author=wildteen88 link=topic=120209.msg493115#msg493115 date=1167390071]
You should use back ticks for those (`). Backticks should only be used when you have a column/table name that has the same name as a reserved keyword.
[/quote]
Which should be never....
Link to comment
https://forums.phpfreaks.com/topic/32119-is-this-wrong/#findComment-149980
Share on other sites

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.