views:

42

answers:

4

I try this in PHPMyadmin:

Update wp_1_posts 
   SET post_content='<strong>Hello </strong> <a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt; you think you're good at sql.\n then answer\n' 
 WHERE post_ti<tle = 'stupid example'

and it says bad syntax. Why ?

+3  A: 

You can see it in your post. The red text ends at the ' in you're. You need to escape the quote. You can simply add \ before it. you\'re.

Brent Baisley
+2  A: 

You have to escape the single quote in the word you're to make it you\'re in your statement.

Imran S.
+3  A: 

With MySQL, single-quotes inside a string have to be escaped, putting a \ before them :

'this is a string with a \' quote inside of it'

As a reference, you can take a look to this section of the MySQL manual :


In your case, your query should look like this :

Update wp_1_posts 
SET post_content='<strong>Hello </strong> <a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt; you think you\'re good at sql.\n then answer\n' 
WHERE post_title = 'stupid example'

Note the \ I've added in think you\'re good.

Pascal MARTIN
+1  A: 

You have to escape quotes inside string (read the manual).

Update wp_1_posts SET post_content='<strong>Hello </strong> <a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt; you think you\'re good at sql.\n then answer\n' WHERE post_title = 'stupid example'
Victor Marzo