gpt4 book ai didi

php - 错误:警告:mysqli_query()至少需要2个参数,其中1个在

转载 作者:行者123 更新时间:2023-11-29 12:12:35 26 4
gpt4 key购买 nike

我收到这两个错误:


  警告:mysqli_query()至少需要2个参数,第11行的/home/shadow28/public_html/register.php中提供了1个参数
  警告:mysqli_num_rows()期望参数1为mysqli_result,在第12行的/home/shadow28/public_html/register.php中给出的null
  您的密钥无效,请与支持人员联系。


这是register.php

<?PHP
require_once("include/config.php");
require('libs/Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'templates';
$smarty->compile_dir = 'temp';
if(isset($_POST['username']) and ($_POST['password']) and ($_POST['key'])){
$username = $_POST['username'];
$password = md5($_POST['password']);
$key = $_POST['key'];
$query = mysqli_query("SELECT * FROM `keys` WHERE `key`='{$key}'");
if (mysqli_num_rows($query) == 1) {
while($row = mysql_fetch_array($query)){
$key1 = $row[0];
$months = $row[1];
$max = $row[2];
$type = $row[3];
}
if($months=="lifetime"){
$months = "lifetime";
}else{
$time = time();
$months = $time + 86400 * $months;
}

$query = mysql_query("INSERT INTO `users` (`login`, `passwd`, `max`, `attacks`, `expiry`, `type`, `key`) VALUES ('".$username."', '".$password."', '".$max."', '100', '".$months."', '".$type."', '{$key}');");
$query = mysql_query("delete from `keys` where `key`='{$key}'");
echo mysql_error();
$smarty->assign("done", "Your account has been added, you can now login.");
}else{
die("Your key isn't valid, please contact support.");
}
}else{
$smarty->assign("done", "");
}

$smarty->display("class.register.tpl");
?>

最佳答案

mysqli需要2个参数,第一个参数应该是您的mysqli_connect()

$link = mysqli_connect("localhost", "dbuser", "dbpass", "dbname");
$query = mysqli_query($link, "SELECT * FROM 'keys' WHERE 'key'='{$key}'");


为什么使用mysql_而不是mysqli_进行INSERT和DELETE查询?

如果与mysql_connect()连接,则不需要mysqli_query($link, "query"),但mysql_query("query")

请注意i后面的mysql

关于php - 错误:警告:mysqli_query()至少需要2个参数,其中1个在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30402310/

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