RE: Error updating db when using a '

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

 



The only thing I see in your code that looks a bit odd are the parens around
your sql statement. I'm not saying that they're causing the problem, just
that I've not seen them used in that manner before.

May I suggest that you echo out the $sql statement to the browser? Then copy
and paste all of the output from this script back to this list. You may
actually figure out what the problem is simply be echoing the $sql back to
the browser though.

Rich

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