Jump to content

Is this wrong?


twilightnights

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.