resolving a problem with the caracter -> ' <- ????

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

Post Reply
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

resolving a problem with the caracter -> ' <- ????

Post by duk »

hy

i need to alow the forms to POST data with the caracter -> ' <- it works fine in some cases like POST data in to the database he put it...

but when i use a variable with that caracter and try to update the database will not work fine, maybe becouse of

Code: Select all

<?php

$sql = "select name from table where name='$x' ";


?>
if the variable x is -> I'Myname <- this will afect the query to the database, becouse the variable $x have the caracter ' ...

how do hy, resolve this problem ??

tanks[/b]
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

Use this function: [php_man]mysql_real_escape_string[/php_man]
Post Reply