Web Hosting Talk







View Full Version : mysql and php form error


unknownhost
11-07-2002, 05:05 PM
Hey guys - I have a php form that submits to a mysql database and there's one last bug - when someone uses the "\" character it errors out. How do I make it treat "\" as part of the string without interrupting the statement or how do I strip the \ from the input:

example code:
$sql = "INSERT INTO affiliates SET " .
"pridomain='$pridomain', " .
"uname='$uname', " .
"upwd='$upwd', " .

error when \ is used:
Error adding your registration entry: You have an error in your SQL syntax near '\'
_________________
The Unknown Host
I Gotta Get A NOC

Ratty
11-07-2002, 06:17 PM
To protect the slashes use the function addslashes()

To remove the slashes alltogether use the function stripslashes()

See :

http://www.php.net/manual/en/function.addslashes.php

and

http://www.php.net/manual/en/function.stripslashes.php