Ion_Cannon Posted June 8, 2009 Share Posted June 8, 2009 Hello, this should be really easy but I am a retard noob to php5 and doing mysql queries. I am stuck. Given this query: Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer` SET `guest`=0 WHERE `email`= $customer->email'); How can I get php to insert the value of 0 into "guest" of the customer table if the field "email" matches $customer->email variable within the code. I can find plenty of examples to match an integer but not a string. Thanks for any help. Sorry to be such an ubenoob. IC Link to comment https://forums.phpfreaks.com/topic/161320-help-with-php5-and-mysql/ Share on other sites More sharing options...
dawsba Posted June 8, 2009 Share Posted June 8, 2009 I had similar problem with a date set dropping the initial 0, wrap the zero in quotes Db::getInstance()->Execute("UPDATE `"._DB_PREFIX_."customer` SET `guest`='0' WHERE `email`= '".$customer->email."'"); Link to comment https://forums.phpfreaks.com/topic/161320-help-with-php5-and-mysql/#findComment-851253 Share on other sites More sharing options...
radi8 Posted June 8, 2009 Share Posted June 8, 2009 not really apropos to the question. The comparison is exactly like the that for an integer: $test_email =$_POST['posted_email']; $val = ($test_email=$customer->email?,0,1); Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer` SET `guest`=$val WHERE `email`= $customer->email'); // OR $test_email =$_POST['posted_email']; if($test_email==$customer->email){ Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer` SET `guest`=0 WHERE `email`= $customer->email'); } Link to comment https://forums.phpfreaks.com/topic/161320-help-with-php5-and-mysql/#findComment-851275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.