Jump to content

Help with php5 and mysql


Ion_Cannon

Recommended Posts

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

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');
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.