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..



-----Original Message-----
From: Aleks @ [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 2:38 PM
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...


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to