my sql select query with table name in french language - php

I have a table named aset_catégorie and when I try to run a select query I'm getting this 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 '©gorie' at line 1
How do I solve this?

SELECT * FROM `aset_catégorie`
You might have missed
` (backtick)
sign...
Hope this helps

Related

SQLSTATE [42000] when adding data

When parsing an xml file and adding it to the database, it displays an error during the script operation:
$sql->exec("INSERT INTO 'example' VALUES('$id', '$title', '$link')");
SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''example'
VALUES('phpmysqljquery-przeciagnij-z-wy'
at line 1
Can anyone say what is wrong?
You're using the wrong quoting style. Database, table and column identifiers use a different approach:
INSERT INTO `example` VALUES (?,?,?)
Double and single quotes are only for strings. You can't insert stuff into a string.

Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your [duplicate]

This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 5 years ago.
I'm really confused right now, keep getting this MySQL error:
Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition='-78' WHERE id='2'' at line 1
While I KNOW that condition is correct, when I remove the condition='".$data['condition']."' from the update record, the update is being processed but when I add that, it fails.
The field in the database is VARCHAR (6), just like all the other fields.
What could be the issue?
condition is a MySQL keyword. You need to enclose it with backticks if you're using it as a column name.
`condition`='-78' WHERE id='2'
Take care: This is the backtick symbol, not the single quote.
condition is a reserved word in MySQL.
You can see the full reserved word list here
You need to wrap condition in backticks;
"UPDATE ..... WHERE `condition`= '".$data['condition']."'";
A note for next time: Please include as much code as is sensible next time. Otherwise it is trickier for people to help you.

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

I have renamed my database in phpMyAdmin but it makes some problems. When I tried to rename it to its first name, it asked first if I want to rename it and drop my database.
When I press OK, it give me this 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 qetary2015-02-21.gps_poss
The SQL query:
ALTER TABLE qetary2015-02-21.gps_poss
How can I fix it please?
At a guess:
ALTER TABLE `qetary2015-02-21`.gps_poss
Wrap the database name in backticks, else the - character might be misinterpreted as a minus sign.... though I hope there's slightly more to your SQL query than that snippet

MySql query - syntax error

The following code is an SQL query that I am using in PHP.
$sql = "INSERT INTO updates (update,user_id_fk)
VALUES ('$post_update','$username')";
It does not work - I get the following error message when it is run.
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 'update,user_id_fk)
This syntax loks fine to me - it is the same as I found on W3Schools.
The mysql verion I am using is 5.5.24
update is a reserved keyword backtick it
INSERT INTO updates (`update`,user_id_fk)
check the list below and in future do not use these words for your table or column names
http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

MySQL - Small query issue

I have a problem with a small query. When I execute it I am getting a error which is
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 'key=stqq WHERE id=75' at line 1
My query is as follows
UPDATE roles SET name=stylistqq, key=stqq WHERE id=75
add quotes
UPDATE roles SET name='stylistqq', key='stqq' WHERE id=75
Are stylistqq and stqq strings? If so, they should have single quotes around them. Pekka's recommendation to use a different column name other than key is also a good idea. You can make MySQL take that string by putting backticks around it, but you'll always need them.

Categories