gpt4 book ai didi

php - mysql 查询不工作给和错误

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:17 26 4
gpt4 key购买 nike

<分区>

大家好,我有两个几乎相同的查询,但一个有效,一个无效这个工作正常:

<?php 
require 'mysql.php';

if(isset($_POST["email"])){
$email = $_POST["email"];

$stmt = $connect->prepare("SELECT email FROM users WHERE email=? ");
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
$rowcount = $result->num_rows;
if ($rowcount > 0){
echo "1";
} else if($rowcount == 0){
echo "0";
}

}
?>

这个不工作,给我一个错误

" Fatal error: Call to a member function bind_param() on a non-object in line 8 "

<?php
session_start();
require 'mysql.php';

$userid = $_SESSION["userid"];

$stmt = $connect->prepare("SELECT * FROM character WHERE userid=? ");
$stmt->bind_param("i", $userid); // line 8
$stmt->execute();
$result = $stmt->get_result();
$rowcount = $result->num_rows;
if ($rowcount > 0){
echo "1";
}else{
echo "0";
}


?>

它们几乎相同,只有第一个检查电子邮件,这个检查用户 ID,但第二个不工作,第一个工作正常问题出在哪里???

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