我有一个转诊脚本这个脚本奇怪的PHP转诊功能的行为
<?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";
}
?>
当我运行此脚本数据库中的行不更新见下文
id | points | referral_id
---|--------|--------
1 | 1000 | 2
2 | 2000 | 0
3 | 1000 | 2
例如EXAMPLE:
if $ uid = 1 & $新= 100 或者 $的uid = 3 & $新= 100
我们需要奖励美元的新=(100 * 25)/ 100 = +25到的ID = 2 = 2,因为ID = 1 & 3已referral_id = 2
id | points | referral_id
---|--------|--------
1 | 1100 | 2
2 | 2000 | 0
3 | 1100 | 2
成功后,我期待的结果是这样
id | points | referral_id
---|--------|--------
1 | 1100 | 2
2 | 2025 | 0
3 | 1100 | 2
脚本成功打印 “1个\ n”;和query1也工作没有query2,当我与query2运行它停止更新数据库,甚至停止打印“1 \ n”;
你需要告诉我们哪里出了问题。你有没有得到一个错误?行不更新? – curt
我正在运行与cron作业整个脚本期望(部分代码)我共享工作,但是当我把这个代码数据库不会得到或存储值,总之是行没有更新 –
有什么建议吗? –