RE: [PHP-DB] Error updating db when using a '
| From: | Aleks @ USA.net | Date: | Thu, 21 Aug 2003 20:05:29 +0000 |
| Subject: | RE: [PHP-DB] Error updating db when using a ' | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-30032@lists.php.net to get a copy of this message | ||
Found the problem.. seems that spanning the sql statement with a carriage
return messed something up. It works fine now..
Sorry about the return receipt earlier... won't happen again..
Thanks
Aleks
-----Original Message-----
From: Aleks @ USA.net [mailto:Aleks.k@usa.net]
Sent: Thursday, August 21, 2003 2:38 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Error updating db when using a '
I have a strange problem.... I am adding records into a MySQL db... there is
a description
column and everything works fine when I add a new record. When I try to edit
an existing
record it fails if I us an apostrophe ['] in the field. I thought that
addslashes would take care
of this but it is not working. Here is the code
// Troubleshooting section Prints out the inform received from the form
echo (" Output received from form <br>");
$A = $_POST['DID'];
echo("$A<br>"); //<- For Troubleshooting
$B = $_POST['DocName'];
echo("$B<br>"); //<- For Troubleshooting
$C = $_POST['Location'];
echo("$C<br>"); //<- For Troubleshooting
$D = $_POST['DocDescrib'];
echo("$D<br>"); //<- For Troubleshooting
// Add slashes to preserve proper formatting in db
$DID = addslashes($A);
$DocName = addslashes($B);
$Location = addslashes($C);
$DocDescrib = addslashes($D);
// SQL used to update the record
// Updates Existing Record
$sql = ("UPDATE MySQL_dB
SET ModDate=CURDATE(), DocName='$DocName', DocDescrib='$DocDescrib',
Location='$Location' where DID='$DID'");
If I do not use the apostrophe in the DocDescrib field this works fine. The
min I introduce one, I get the following error:
Error adding new Data: you have an error in your SQL syntax near 's
Thanks in advance for your assistance...
Aleks