For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2004 > Re: [PHP-DB] Problem with update-command









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Problem with update-command
Jeffrey N Dyke

2004-04-22, 9:32 am





>$result=mysql_db_query("usr_172_1","UPDATE artikel SET Preis='\$preis'

WHERE ID='\$id'");
>//mysql_error($result);


Here you're escaping the $ and then the ', have you tried....

$result=mysql_db_query("usr_172_1","UPDATE artikel SET Preis='{$preis}'
WHERE ID='{$id}'");
with those escapes this is the actual query you're sending....
"UPDATE artikel SET Preis='$preis' WHERE ID='$id'"

HTH
Jeff


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

2004-04-22, 9:32 am

"Jeffrey N Dyke" <jeffrey_n_Dyke@Keane.com> wrote in message
news:OFC83F9145.CF6BE5D5-ON85256E7E.0041F0E4@keane.com...
> WHERE ID='\$id'");
>
> Here you're escaping the $ and then the ', have you tried....
>
> $result=mysql_db_query("usr_172_1","UPDATE artikel SET Preis='{$preis}'
> WHERE ID='{$id}'");
> with those escapes this is the actual query you're sending....
> "UPDATE artikel SET Preis='$preis' WHERE ID='$id'"


Good point, Jeff. As the id is probably an int one doesn't need quotes at
all:

"UPDATE artikel SET Preis='" . $preis . "' WHERE ID=" . $id

Regards,
Torsten

>
> HTH
> Jeff

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com