Page 1 of 1

Help......Passing Search string containing single quotes

Posted: Mon Mar 19, 2007 6:49 pm
by anirbanb2004
Hi I am trying to write a code that is simple..I will pass a variable $word and it will search all the rows in a MySql table.
Now If the string in $word contains single quote(') then it is creating problem.
Please help me It is very important... :(

Code: Select all

$string=$_POST['name']; 

$query="select * from Words where Word='$string'"; 
$result=mysql_query($query);
Now if $string ="Citta' " then it will create problem.....

Posted: Mon Mar 19, 2007 6:56 pm
by Skara

Code: Select all

$string = mysql_real_escape_string($_POST['name']);