mysql - strange behavior of php referral function -


i have referral script script

<?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 users id=".$uid);  $rows = mysql_fetch_array($users);  $user_points = $rows['points'];  $query1 = mysql_query("update users set points=($user_points+$new/2) id=$uid ");   //updating referral coins          $query2 = "select points, referral_id users 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' id = ".$all['referral_id'];              mysql_query($update_referral_points);                      }          } else {             print "0\n"; } ?> 


when run script database rows not updating see example below

    id | points | referral_id     ---|--------|--------     1  | 1000   | 2     2  | 2000   | 0     3  | 1000   | 2 

for example:

if $uid = 1 & $new = 100 or $uid = 3 & $new = 100
need award $new= (100*25)/100 = +25 id=2 in id = 2 because id = 1 & 3 has referral_id = 2

    id | points | referral_id     ---|--------|--------     1  | 1100   | 2     2  | 2000   | 0     3  | 1100   | 2 

after success expecting results this

    id | points | referral_id     ---|--------|--------     1  | 1100   | 2     2  | 2025   | 0     3  | 1100   | 2 

the script print "1\n"; , query1 working without query2 , when run query2 stop updating database , stop print "1\n";

in update query, clause should be; id = ".$all['referral_id'] because referral_id id of referrer.

your code may susceptible sql injection.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -