here is my code which I pass two variables from android studio to php. xampp has both apache and MySQL running on the default ports. my aim is to compare variables got from android studio with ones in the database table; but i get an error that says:
Uncaught Error: Call to a member function bindParam() on boolean in C:\xampp\htdocs\digikala\index.php:10 Stack trace: #0 {main} thrown in C:\xampp\htdocs\digikala\index.php on line 10.
I should also mention windows 10 pro is running on my system. could any of you guys could help me get over this problem? thanks in advance. here is my connect.php code:
<?php
function OpenCon()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "digikala";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
return $conn;
}
function CloseCon($conn)
{
$conn -> close();
}
?>
and this is my main code which error belong to. if I remove bindParam and put $email and $pass directly in sql code the same error happens for line contains $result->execute():
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include "connect.php";
$email=$_POST["user"];
$pass =$_POST["pass"];
$conn = OpenCon();
$query = 'SELECT * FROM member WHERE email=:email AND pass=:pass';
$result= $conn->prepare($query);
$result->bindParam(':email',$email);
$result->bindParam(':pass',$pass);
$result->execute();
$row = $result->fetch(PDO::FETCH_ASSOC);
if ($row == false ){
echo("not existed!");
}else{
echo("welcome" . $email);
}
CloseCon($conn);
?>