PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shafiq2626
Forum Commoner
Posts: 88 Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:
Post
by shafiq2626 » Tue May 12, 2009 9:24 am
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
Last edited by
Benjamin on Tue May 12, 2009 11:37 am, edited 1 time in total.
Reason: Changed code type from text to php.
shafiq2626
Forum Commoner
Posts: 88 Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:
Post
by shafiq2626 » Tue May 12, 2009 10:04 am
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
you can do it and be relax
Last edited by
Benjamin on Tue May 12, 2009 11:37 am, edited 1 time in total.
Reason: Changed code type from text to php.
Defiline
Forum Commoner
Posts: 59 Joined: Tue May 05, 2009 5:34 pm
Post
by Defiline » Tue May 12, 2009 10:55 am
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.