数据库没有被php页面更新,我无法弄清楚原因

时间:2018-05-03 17:26:07

标签: php mysqli

我正在尝试通过回发为用户添加积分。脚本如下。我的服务器返回200 Ok响应,但数据库中的点没有变化。 PHP对我来说不是一项强大的技能,所以任何帮助都会受到赞赏。代码低于我的数据库凭据......

我也得到一个Not Indexed错误:PHP注意:未定义索引:第21行/home/bitcftyy/public_html/postback.php中的SB1

回发网址:https://bitcoinincome.website/postback.php?points=[CUR]&subid=[SB1]

<?php
// Connecting to database, using MySqli
$mysqli = new mysqli('localhost', 'xxxxxxx', 'xxxxxx', 'xxxxxxx');

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

// Insert log into database
$stmt = $mysqli->prepare("UPDATE users SET points = points+(?) WHERE id = 
(?)");
$stmt->bind_param('ii', $points, $subid);

// Setup postback variables
$points = $_REQUEST['CUR'];
$subid = $_REQUEST['SB1'];

$stmt->execute();

//printf("%d Row updated".\n", $stmt->affected_rows);
printf("%d Row updated, added " .$points. " to user " .$subid. 
".\n",mysqli_stmt_affected_rows($stmt));
$stmt->close();
$mysqli->close();
?>

1 个答案:

答案 0 :(得分:0)

这是你的回发网址

https://bitcoinincome.website/postback.php?points=[CUR]&subid=[SB1]

更改这两行

$points = $_REQUEST['CUR'];
$subid = $_REQUEST['SB1'];

$points = $_REQUEST['points'];
$subid = $_REQUEST['subid'];

这应该可以正常工作