...

View Full Version : Update not successfull : why ??



mOrloff
03-23-2010, 05:55 PM
I am able to successfully run sqlsrv SELECT querys, but my UPDATE is returning false.

Here's what I've got:


$stockPN='TEST ITEM 2';
$newDesc='UPDATE SUCCESSFUL';
$updateSQL="UPDATE partrecord SET description=\'$newDesc\' WHERE fullpartnumber=\'$stockPN\' AND quantity>0";
$update=sqlsrv_query($rzConn,$updateSQL);
echo '<pre>';
var_dump($update);
echo '</pre>';


Am I doing something wrong ?
~ Mo

angst
03-23-2010, 06:34 PM
try;



$updateSQL="UPDATE partrecord SET description='" . $newDesc . "' WHERE fullpartnumber='" . $stockPN . "' AND quantity > 0";

mOrloff
03-23-2010, 06:57 PM
Thanks !
That did it !!
But ... why?
Aren't those two options basically the same ??

~ Mo

angst
03-23-2010, 07:00 PM
no, $newDesc is a string and should be wrapped in quotes, however you escaped the quotes which was causing the update to fail.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum