我有这个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
。知道为什么吗?
最佳答案
您需要先定义:$dbc
$code = mysqli_real_escape_string ($dbc, $_GET['invite']);
前任:
$dbc = mysqli_connect("localhost", "my_user", "my_password", "world");