![](/img/trans.png)
[英]Laravel - [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ip.priorities' doesn't exist
[英]'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1932 Table 'bookstore.user' doesn't exist in engine'
這段代碼以前工作過。 現在,當我嘗試登錄時沒有。這是我得到的錯誤。
致命錯誤 :
消息'SQLSTATE [42S02]未捕獲的異常'PDOException':未找到基表或視圖:1932表'mhaonlineshop.users'在引擎中不存在'........ DO-> query('select * FROM t ...')#1 {main}在第23行的H:\\ Aston University \\ New folder \\ htdocs \\ xampp \\ login.php中引發((此行的代碼= $ result = $ db-> query( $查詢);))
我非常感謝如何解決該問題。 謝謝。
<?php
session_start();
include ("db_connect.php");
include("shared.php");
if (isset($_POST['submitted'])){
$username = $_POST['ID'];
$password = $_POST['password'];
$db = new PDO("mysql:dbname=mhaonlineshop;host=localhost", "root", "");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "select * FROM users where ID= '$username' AND password = '$password'";
$result = $db->query($query);
if ($result -> rowCount()==1){
$firstrow = $result->fetch();
$_SESSION['ID'] = $firstrow[0];
$_SESSION['money'] = $firstrow[6];
$_SESSION['admin'] = $firstrow[5];
if ($_SESSION['admin'] == "0"){
header("Location: mhaonlineshopcatalogue.php");
}else if ($_SESSION['staff'] == "1"){
header("Location: cart.php");
}
} else {
echo "<h1>Please enter correct password</h1>";
}
}
?>
除了代碼中的嚴重安全性問題外,上述消息還指出表用戶不在數據庫中。 您檢查數據庫了嗎?
關於安全性問題:想象一下,當用戶進入時會發生什么
' OR password LIKE '%
作為用戶名或密碼...
...您永遠不要在查詢中使用未經消毒的post var字符串。 (並且也不將普通密碼存儲到數據庫;請考慮使用哈希密碼。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.