Page 1 of 1

Handle double quotes " with value

Posted: Tue May 12, 2009 9:24 am
by shafiq2626
Hello!
How to handle " with value to insert in mysql query.

like

Code: Select all

$nId = $this->InsertTable('actor',"Name, Rate,Path","\"".$this->name."\",\"" .$this->rate."\",\"" .$this->path."\"");
single quotes and semicolon handle by this code but if insert double quotes like " with value like abc" then give error

pls Please help ASAP.

thanks

Re: Solved To Handle double quotes " with value

Posted: Tue May 12, 2009 10:04 am
by shafiq2626
Hello!

I wrote a function

Code: Select all

function quote( $text )
    {
        if ( get_magic_quotes_gpc() )
            $text = stripslashes($text);
 
        return '\'' . mysql_real_escape_string($text) . '\'';
    }
and pass every value to this function

like

Code: Select all

$connet->quote($_POST['name']);

you can do it and be relax

Re: Handle double quotes " with value

Posted: Tue May 12, 2009 10:55 am
by Defiline
Does it work? :)
No, It doest not.

Code: Select all

 
function quote($text) {
    if (get_magic_quotes_gpc()) {
        $text = stripslashes($text);
    }
    
    return mysql_real_escape_string($text);
}
But it is not correct still.