Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql acting very strange with update. please help, I've been stuck on this for a full day now
    primarykey
    data
    text
    <p>I've been stuck with this for a full day now and this is the longest I've been stuck coding ever. Please Help me.</p> <p>I have the following code, it is a paypal ipn URL used to verify an account on a database. I first connect to sql etc. then get the users information from paypal then get the users information from the database. Before paying, the user should have the value of 'unverified' in the user_level column and if 'unverified' it should be updated. </p> <p>Here is the strange thing that I'm stuck at. The value of user_level is never 'unverified' even though I've checked in the actual database, before running the code, that it is in fact 'unverified'. But when I comment out the mysql_query($u), it gives the value 'unverified'. </p> <p>What is happening is that it seems to be updating the record before the actual code is being called to check whether to update it or not.</p> <p>Please help anybody, I would appreciate it greatly. I </p> <pre><code>$sql_connect = @mysql_connect($_SERVER['HTTP_HOST'].':3306','root', '******') or die('Could not connect: ' . mysql_error()); mysql_select_db('4bkk'); $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; $postFields = 'cmd=_notify-validate'; foreach($_POST as $key =&gt; $value) { $postFields .= "&amp;$key=".urlencode($value); } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL =&gt; $url, CURLOPT_RETURNTRANSFER =&gt; true, CURLOPT_SSL_VERIFYPEER =&gt; false, CURLOPT_POST =&gt; true, CURLOPT_POSTFIELDS =&gt; $postFields )); $result = curl_exec($ch); curl_close($ch); if($result=='VERIFIED'){ $log = 'Verfied --- '; //get buyers information from PAYPAL checkout $email = $_POST['payer_email']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $amount = $_POST['amount3']; $plan = $_POST['option_selection1']; $q = "SELECT * FROM users WHERE email='$email'"; $data = mysql_query($q); $con = mysql_fetch_array($data); //get buyers information from DATABASE $email2 = $con['email']; $first_name = $con['first_name']; $last_name = $con['last_name']; $active = $con['active']; $user_level = $con['user_level']; $log .= $first_name.' , '.$last_name.' , '.$email2.' , '.$active.' , '.$user_level.' **************** '.$email ; if($email2==$email){ //User already has a record if($user_level=='unverified'){ // User unverified, ready for verification $log .= 'Emails match, and user is VERIFIED'; $u = "UPDATE users SET active='verified', user_level='$plan' WHERE email='$email' LIMIT 1"; $log .= $u; mysql_query($u); } else{ // User is already verified, $log .= 'Emails match, BUT user is NOT VERIFIED'; } } else{ //User doesn't have a record $log .= 'Emails DONT match, execute update here'; } $fh = fopen('result_ipn_test.txt', 'w'); //fwrite($fh, $subject.' --- '.$message); fwrite($fh, $message.' ********** '.$log); fclose($fh); } else echo 'INVALID'; mysql_close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload