在PHP中逃避MySQL查询 - mysql_query()更新什么都不做

In my php script for a gallery, I need to update my table.
I am using the following code, but the code does nothing:

mysql_query(' "update gallery_photos set photo_caption = replace(photo_caption,"\\\'","\'") "');

Can you tell me how to get it to work or point me in the right direction?

Try this with removing single quotes at start and end.

mysql_query("update gallery_photos set photo_caption = replace( photo_caption,'\\\'','\'') ");

Try

mysql_query("UPDATE gallery_photos SET photo_caption = REPLACE(photo_caption,'\\\'','\'') ");

You have the escaping and ' and " mixed in a wrong way.

The thing is, there are two unescapings: Once in PHP, then in MySQL.

So '\\\\' becomes "\\" in PHP and then "\" in MySQL.

And now I found out that even StackOverflow spoils it for us as it unescapes too. So to write "\\" here I had to write "\\\\" :)

try doing this

$que = mysql_query("select * from gallery_photos");
$fet = mysql_fetch_object($que);
$pc  = $fet->photo_caption;
$pc2 = replace($pc,"'\\\'","'\'") ;

$update = mysql_query("update gallery_photos set photo_caption='$pc2'");

if (!$update) {
  echo "Error : <br>";
  echo "".mysql_error()."";
}else {
  echo "Updated ..!!";
}