views:

148

answers:

5
UPDATE `test`.`documents` SET `title` = ‘测试中文’, `content` = ‘this is my test document number two,应该搜的到吧’ WHERE `documents`.`id` = 2;


#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 'my test document number two,应该æ

i used axmpplite, and mysql's version is 5.1.37

thanks

alt text

2.

i chaged the wrong ',and still error.

UPDATE 'test'.'documents' SET 'title' = '测试中文', 'content' = 'this is my test document number two,应该搜的到吧' WHERE 'documents'.'id' = 2;

#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 ''test'.'documents' SET 'title' = '测试中文', 'content' = 'this is my test do' at line 1

alt text

3 i used mike's answer,it is ok,but see:

alt text

it is all show ??????

4.this is my show variables like 'char%'; alt text

how do i set my my.ini ???

and alt text

thanks

+2  A: 

You're using ‘, instead of ', (that is, weird inverted commas)

For your new problem, you need to use `s (backticks) instead of ' (inverted commas) if you want to quote a table or column name.

Seadog
Weird inverted apostrophes AKA "smart quotes". They'll get you every time... this query must have been copied/pasted from somewhere.
Aaronaught
A: 

Without knowing exactly where and how you're using that SQL statement, I can only guess that it could be an encoding problem. Try to change the encoding to UTF-8.

aberrant80
how to change the database(already exist) to utf-8 in xampplite ??thanks
zjm1126
Sorry, it's been a long time since I've used MySQL, so my answer is just a guess. You can check their doc http://dev.mysql.com/doc/refman/5.0/en/internationalization-localization.html and see if you find anything. I suspect it's a configuration file that you need to edit. Not sure about converting an already-existing DB though.
aberrant80
+1  A: 

Left and right single quotes ( and ) should be replaced by normal apostrophe (').

Or is it called straight single quote?

o.k.w
A: 

all mysql table and field names should be escaped with backticks: ` all mysql strings should should be enclosed with single quote: ' try this:

UPDATE `test`.`documents` SET `title` = '测试中文', `content` = 'this is my test document number two,应该搜的到吧' WHERE `documents`.`id` = 2;

to address #3: you need to alter the default charset for that table: "ALTER TABLEtest.documents. CONVERT TO CHARACTER SET utf8;" Be careful though, this may change the storage size requirements of the table, so if it's a large table, plan for the query to take a bit to execute.

to address #4: you should add the following to the [mysqld] section of my.ini:

collation_server=utf8_unicode_ci
character_set_server=utf8
Mike Sherov
hi mike ,your answer is ok,but see my 3
zjm1126
responded in answer above.
Mike Sherov
#4 addressed as well
Mike Sherov
A: 
UPDATE test.documents
SET title = '测试中文',
content = 'this is my test document number two,应该搜的到吧'
WHERE documents.id = 2; 

is also ok,and the same question is also my 3

zjm1126