我有这个PHP页面:
<?php //$_GET['invite'] = kNdqyJTjcf; $code = mysqli_real_escape_string ($dbc, $_GET['invite']); $q = "SELECT invite_id FROM signups_invited WHERE (code = '$code') LIMIT 1"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_num_rows($r) == 1) { echo 'Verified'; } else { echo 'That is not valid. Sorry.'; } ?>
这将返回错误Warning: mysqli_error() expects parameter 1 to be mysqli, null given。
Warning: mysqli_error() expects parameter 1 to be mysqli, null given
知道为什么吗?
您需要定义:$dbc之前
$dbc
$code = mysqli_real_escape_string ($dbc, $_GET['invite']);
例如:
$dbc = mysqli_connect("localhost", "my_user", "my_password", "world");