Ehsan_Nawaz Posted May 4, 2023 Share Posted May 4, 2023 <?php include("db_connect.php"); if(isset($_POST["login"])){ require("config.php"); global $database; $stmt = $database->prepare("SELECT * FROM single WHERE email=:email"); $stmt->bindParam(":email", $_POST["email"]); $result = mysqli_query($conn, $sql); $stmt->execute(); $count = $stmt->rowCount(); if($count == 1){ $row = $stmt->fetch(); if($_POST["pass"] == $row["pass"]){ ($row["PASSWORD"]) ($_POST["pw"]) session_start(); $_SESSION["email"] == $row["email"]; header("Location: dashboard.php"); } else { echo "login Success"; } } else { echo "Login Error"; } } Fatal error: Uncaught Error: Call to a member function prepare() on string in C:\xampp\htdocs\mysqlilogin\Adminframe.php:35 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mysqlilogin\Adminframe.php on line 35 Quote Link to comment https://forums.phpfreaks.com/topic/316254-please-identify-my-problem/ Share on other sites More sharing options...
Barand Posted May 4, 2023 Share Posted May 4, 2023 It would appear that your $database variable contains a string and not a PDO object. Your use of GLOBAL is incorrect. Quote Link to comment https://forums.phpfreaks.com/topic/316254-please-identify-my-problem/#findComment-1608043 Share on other sites More sharing options...
Ehsan_Nawaz Posted May 4, 2023 Author Share Posted May 4, 2023 it is not a pdo method its is mysqli method here is my db_connection file <?php if (isset($HTTP_GET_VARS)) extract($HTTP_GET_VARS); if (isset($HTTP_POST_VARS)) extract($HTTP_POST_VARS); include("config.php"); $link=mysqli_connect($host_name,$user_name,$password); if (! $link) die ( "MySQL error !"); mysqli_select_db($link,$database) or die ( "mysqlerror $database :".mysqli_connect_error() ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/316254-please-identify-my-problem/#findComment-1608044 Share on other sites More sharing options...
Barand Posted May 4, 2023 Share Posted May 4, 2023 According to that connection code, you should be using $link->prepare() Quote Link to comment https://forums.phpfreaks.com/topic/316254-please-identify-my-problem/#findComment-1608046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.