Jump to content

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

 

 

 

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.