Jump to content

[SOLVED] SQL syntax error


2DaysAway

Recommended Posts

I'm getting this 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 '-_cartelz.ratings WHERE id='8'' at line 1

 

Here is the query:

 

$query = mysql_query("SELECT total_votes, total_value, used_ips FROM $rating_dbname.$rating_tableName WHERE id='$id_sent' ")or die(" Error: ".mysql_error());

 

I've checked my config page, the db info is correct and the table info is correct

 

Is the query written correctly?

 

 

Link to comment
https://forums.phpfreaks.com/topic/88091-solved-sql-syntax-error/
Share on other sites

ok, i added backticks:

$query=mysql_query("SELECT `total_votes, total_value, used_ips` FROM `$rating_dbname.$rating_tableName` WHERE id='$id' ")or die(" Error: ".mysql_error());

Now I get this error:

Error: Incorrect table name 'cartelz_com_-_cartelz.ratings'

 

ratings is the correct table name.

same result.

 

I updated my previous post. Backtick marks should be around the DB name (and table name).

 

If you get an error again, and I doubt it, always post current code/query and exact error. Thx.

 

See manual:

 

http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

 

 

 

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.