title: strange behavior of php referral function
body: <p>I have a referral script this script</p>
  
  <pre><code>&lt;?php
  ob_start();
  define('DB_HOST', 'localhost');
  define('DB_NAME', 'dbnamehere');
  define('DB_USER', 'dbuserhere');
  define('DB_PASS', 'dbpasshere');
  mysql_connect(DB_HOST,DB_USER,DB_PASS);
  mysql_select_db(DB_NAME);
  $id = $_REQUEST['id']; 
  $uid = $_REQUEST['uid']; 
  $oid = $_REQUEST['oid']; // completed offer or payment method
  $new = $_REQUEST['new']; 
  $total = $_REQUEST['total'];
  $sig = $_REQUEST['sig'];
  $timestamp = date("Y-m-d H:i:s");
  
  // Secrete Key
  $key = 'e5870b6ab402d790a5d6bd1cefaee7c4';
  
  // Compare results
  $hash = md5($id.':'.$new.':'.$uid.':'.$key);
  
  // Output results
  if ($sig == $hash) {
  
          print "1\n";
  
  
  //Users point update query here
   $users = mysql_query("SELECT points FROM users WHERE id=".$uid);
   $rows = mysql_fetch_array($users);
   $user_points = $rows['points'];
   $query1 = mysql_query("update users set points=($user_points+$new/2) where id=$uid ");
  
  
  //Updating referral coins 
          $query2 = "select points, referral_id from users where referral_id=".$uid;  
          $user_rows = mysql_query($query2);
          $all=mysql_fetch_array($user_rows,MYSQL_BOTH);
          if($all['referral_id'] != 0){
               echo $referal_points = intval((25/100) * $new);
               $update_referral_points = "update users set points = points + '$referal_points' WHERE id = ".$all['referral_id'];
               mysql_query($update_referral_points);
  
                      }
  
          } else {
              print "0\n";
  }
  ?&gt;
  </code></pre>
  
  <p><br>
  <strong>When i run this script database rows not updating see example below</strong></p>
  
  <pre><code>    id | points | referral_id
      ---|--------|--------
      1  | 1000   | 2
      2  | 2000   | 0
      3  | 1000   | 2
  </code></pre>
  
  <p><strong>For Example:</strong></p>
  
  <p>if $uid = 1 &amp; $new = 100
  Or 
  $uid = 3 &amp; $new = 100<br>
  we need to award $new= (100*25)/100 = +25 to id=2 in id = 2 because id = 1 &amp; 3 has referral_id = 2 </p>
  
  <pre><code>    id | points | referral_id
      ---|--------|--------
      1  | 1100   | 2
      2  | 2000   | 0
      3  | 1100   | 2
  </code></pre>
  
  <p><strong>After Success i am expecting results like this</strong></p>
  
  <pre><code>    id | points | referral_id
      ---|--------|--------
      1  | 1100   | 2
      2  | 2025   | 0
      3  | 1100   | 2
  </code></pre>
  
  <p>The script successfully  print "1\n"; and query1 also working without query2 and when i run with query2 it stop updating database and even stop print "1\n";</p>