i'm still learning about php ,please help me to find the answer for this
Uncaught Error: Call to a member function prepare() on null in C:\xampp\htdocs\eCommerece\Admin\index.php:15 Stack trace: #0 {main} thrown in C:\xampp\htdocs\eCommerece\Admin\index.php on line 15

 
<?php
$dsn='mysql:host=localhost;dbname=shop';
$User='root';
$pass='';
try{
	$con=new PDO($dsn,$User,$pass);
	echo "Your Good Connection";

}
catch(PDOException $e){
echo"Thats Error Connection".$e->getmessage();


}
?>
///////////////////////////////////////////////////////////////
<?php

include 'init.php';

include $init;

include 'includes/language/eng.php';
if($_SERVER['REQUEST_METHOD']=='POST'){
$username=$_POST['user'];
$Password=$_POST['pass'];
$embededpass=sha1($Password);
 


 $stmt=$con->prepare("SELECT UserName , password FROM user WHERE UserName = ? AND password");
 $stmt->excute(array($username,$embededpass));


}

?>

    Which line is line 15?
    $username=$POST['user']; should be $username=$_POST['user'];
    WHERE UserName = ? AND password"); should be WHERE UserName = ? AND password = ?");

    Added [code]...[/code] tags to the original post -- please use in future posts. 😉

    Change include to require and see if that throws an error that would then indicate it's not able to read the file you specified.

    a month later
    Write a Reply...