Separators in variable values causing MySQL commands to fail
| From: | rentAweek Ltd | Date: | Sat, 22 Mar 2003 17:50:30 +0000 |
| Subject: | Separators in variable values causing MySQL commands to fail | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140695@lists.php.net to get a copy of this message | ||
In my PHP script I have coded e.g.:
$sql = "INSERT INTO
$owners ( FirstName, LastName) VALUES ( '$firstname' , '$lastname' )";
$result = mysql_query($sql);
So along comes e.g. John O'Groats and nothing gets inserted into the database.
OK, I can bypass my oversight by stripping out apostophes from the variable values. There has to be a better way please.
TIA
Mike