我正在尝试为在登录用户打开某个页面后引用登录用户的用户增加价值
所以我做了一些更改,我现在收到以下错误
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
in C:\xampp\htdocs\test\goingback_t_play_150.php on line 18
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
C:\xampp\htdocs\test\goingback_t_play_150.php on line 20
,
这是我的代码
<?php
session_start();
?>
<?php
// Adjust MySQL connection settings...
$mysql_hostname = "localhost";
$mysql_user = "user";
$mysql_password = "";
$mysql_database = "";
$bd = mysql_connect($mysql_hostname, $mysql_user,$mysql_password) or die("");
mysql_select_db($mysql_database, $bd) or die
$sql="SELECT * FROM users where id={$_SESSION['refcode']}";
$val = 2; //#2 : Why do u need the ()?
$result = mysql_query($sql,$bd);
$data=mysql_fetch_assoc($result);
if (mysql_num_rows($result)==1) {
// equate the value to a variable to use outside
// this while loop
$acc_balance = $data['com_balance'];
$commision = $data['id'];
}
$remainder = $acc_balance + $val;
$update_query = mysql_query("UPDATE users SET com_balance = '".
mysql_real_escape_string($remainder) ."'
WHERE id='refcode'");
if ($update_query) {
print "";