twilightnights Posted December 28, 2006 Share Posted December 28, 2006 [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. Quote Link to comment Share on other sites More sharing options...
printf Posted December 29, 2006 Share Posted December 29, 2006 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 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 29, 2006 Share Posted December 29, 2006 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 30, 2006 Share Posted December 30, 2006 [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.... Quote Link to comment Share on other sites More sharing options...
artacus Posted January 1, 2007 Share Posted January 1, 2007 [code]Which should be never....[/code]Then you're never had to follow up any newbie coders. They seem to have a penchant for naming columns after their type... "timestamp" seems to be an almost irresistible column name. LOL Quote Link to comment Share on other sites More sharing options...
fenway Posted January 3, 2007 Share Posted January 3, 2007 And apparently "group" too, according to a recent post -- and no, I don't hire newbie coders, or if I do, I give them a DB schema to work with. Quote Link to comment 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.