HElp..The search string passed into mysql query having singl

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

Locked
anirbanb2004
Forum Newbie
Posts: 23
Joined: Sun Oct 15, 2006 4:21 pm

HElp..The search string passed into mysql query having singl

Post 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);
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

If you keep duplicate posting you'll get banned. Stop now.

mysql_real_escape_string()
Locked