SQL query problem
| From: | Mike Dugas | Date: | Mon, 05 Jun 2000 15:26:47 +0000 |
| Subject: | SQL query problem | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-204@lists.php.net to get a copy of this message | ||
Hi y'all,
I'm having a problem with a PHP app I've written. It takes data from form
fields, and inserts it into the database... Simple, right? :) Well, to
start, heres my SQL query to update the database:
mysql_query ("REPLACE INTO members
(id, username, password, fname, lname, location, aim, icq, email,
carmake, carmodel, caryear, carengine, cartrans, carcolor,
carinterior, engmods, suspmods, intmods, extmods, audiomods,
miscmods, futuremods, tfmtitle)
VALUES
('$id', '$username', '$password', '$fname',
'$lname', '$location',
'$aim', '$icq', '$email', '$carmake',
'$carmodel', '$caryear',
'$carengine', '$cartrans', '$carcolor', '$carinterior',
'$engmods', '$suspmods', '$intmods', '$extmods',
'$audiomods',
'$miscmods', '$futuremods', '$tfmtitle')");
Ok... Now. I have someone entering data into the fields, and its all well
and good until he gets to the "futuremods" field, where he enters the
following data: (without the quotes, of course)
"NOS with Gen-X system, Freedom Design Strut Bar, Window Tint, Complete
Upgraded Brake System, Andy's or FX Ground Effects Kit, RK Sport Ram Air
Hood, RK Sport White Gauge Overlay, Aftermarket Struts, Redo Entire Stereo
System, Red Carbon Fiber Dash Kit, RK sport Red Carbon Fiber Chevy Badges,
Rk sport Touring Wing, GRD's TPS-TEC, Turbo"
And when he clicks submit, to update his record, I turned on the
mysql_error() statement, and he gets this:
1064: You have an error in your SQL syntax near 's or FX Ground Effects
Kit, RK Sport Ram Air Hood, RK Sport White Gauge Overla' at line 8
I understand what the problem is (the apostrophe)... But I don't
understand WHY its a problem, exactly, or how to fix it.
Anyone care to help?
TIA.
--
Mike Dugas mad@phobia.net