Search code examples
phpmysql-real-escape-string

mysql_real_escape_string() leaves slashes to my image tag when re submitting page


$a = mysql_real_escape_string(strip_list_words($a));

$query = "update r set answer='{$a}' WHERE id = '{$id}'";

When the page gets "saved" (re-submitted) the frame that the "answer" (image) is display goes from:

img src="/Images.php?imageId=b9129d0e96f1be14a4a0" alt="test5.png"

TO

img src="\"/maint/reportsImages.php?imageId=b9129d0e96f1be14a4a0\"" alt="\"test5.png\"">

How can I convert this or change the way it gets saved/refreshed with mysql_real_escape_string


Solution

  • if (get_magic_quotes_gpc()){
      $a= stripslashes($a);
    }
    if (function_exists('mysql_real_escape_string')) {
      $query = mysql_real_escape_string($a);
    } else {
      $query =  mysql_escape_string($a);
    }