php column not found,Uncaught PDOException: SQLSTATE[42S22]: Column not found in PHP code

I get this message:

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Password' in 'field list' in C:\xampp\htdocs\eCommerce\admin\index.php:26 Stack trace: #0 C:\xampp\htdocs\eCommerce\admin\index.php(26): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\eCommerce\admin\index.php on line 26

It says that the error comes from this line:

$stmt->execute(array($username, $hashedPass));

session_start();

$noNvabar = '';

if(isset($_SESSION['Username'])){

header('Location: dashboard.php');//Redirect to dashboard page

}

include 'init.php';

// Check if the user coming from an http post request

if ($_SERVER['REQUEST_METHOD'] == 'POST'){

$username = $_POST['user'];

$password = $_POST['pass'];

$hashedPass = sha1($password);

// Check if the user exist in the database

$stmt = $con->prepare("SELECT Username, Password FROM users WHERE Username = ? AND Password = ?");

$stmt->execute(array($username, $hashedPass));

$count = $stmt->rowCount();

// If count > 0 this means the database contains record about this username

if ($count > 0) {

echo 'welcome' . $username;

$_SESSION['Username'] = $username; // Register Session Nmae

header('Location: dashboard.php'); // Redirect to dashboard page

exit();

}

}

?>

Admin Login

include $tbl . 'footer.php';

?>

# Answer 1

4d350fd91e33782268f371d7edaa8a76.png

Please read the message:

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Password' in 'field list' in C:\xampp\htdocs\eCommerce\admin\index.php:26

==>

$stmt = $con->prepare("SELECT Username, Password FROM users WHERE Username = ? AND Password = ?");

Password is not found in the users table.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值