RE: Error updating db when using a '

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux