gpt4 book ai didi

php - mysqli_error() expects parameter 1 to be mysqli, null given 是什么意思?

转载 作者:可可西里 更新时间:2023-11-01 06:54:05 26 4
gpt4 key购买 nike

我有这个 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");

关于php - mysqli_error() expects parameter 1 to be mysqli, null given 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7457191/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com