Problems with SQL queries in PHP script
| From: | Mike Hilty | Date: | Sat, 08 Feb 2003 17:18:18 +0000 |
| Subject: | Problems with SQL queries in PHP script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-134879@lists.php.net to get a copy of this message | ||
Hello,
I am running into an issue where when a user inputs an apostrophie '
into the textarea section of my form, it will generate an error in the SQL
statement.
I have narrowed down the issue to this snippet of code:
$insertQuery = "INSERT INTO changeLog(vendorNumber, newVendorNumber,
oldName, newName, changedBy, dateChanged, comments)
VALUES('$vendorNumber','$newVendorNumber','$oldName','$newName','$changedBy'
,'$dateChanged','$comments')";
The thing that is causing this issue is the use of apostrophies to
designate my variables in the SQL query. How do I rewrite this to avoid
this issue?
Thanks,
Mike Hilty