Hello guys i have two almost same querys but one is working and one not this one is working fine :
<?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";
}
}
?>
and this one is not working and gives me an error
" 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";
}
?>
they are almost same only first one checks email and this one checks userid but second one are not working and first one are working fine where is the problem ???