I have php configured so that is automatically creates slashes before single quote or double quotes in strings that are passed from page to page.

When I try to insert a string into MySql dbase, the single quotes will insert fine, but at the first double quote the string terminates and isn't saved into the dbase.

I would like to be able to html encode my strings so that double quotes are saved into the dbase as:

"

I have tried using the below code but it does not convert quote symbols.

<?php
$new = htmlspecialchars($var, ENT_QUOTES);
echo $new;
?>

Can someone advise me how to achieve this?[

    you can use [man]addslashes[/man] before inserting into the database to prevent errors.

    But if you still want to use &amp;quot;

    $new = str_replace("\"","&quot;",$var);
    

    should do the trick.

      Write a Reply...