gpt4 book ai didi

php - 非静态方法 PDO::quote() 不能静态调用,

转载 作者:太空宇宙 更新时间:2023-11-03 11:45:13 24 4
gpt4 key购买 nike

Error i get from WAMP

$username = $_POST['username']; 
$password = $_POST['password'];


$db = new PDO('mysql:host='.$DB_HOST.';dbname='.$DB_DATABASE.'', ''.$DB_USER.'', ''.$DB_PASSWORD.'');

$query = $db->query("SELECT * FROM login_details WHERE username=:username AND password=:password");
$query->bindValue(':username', $username, PDO::PARAM_STR);
$query->bindValue(':password', $password, PDO::PARAM_STR);
$query->execute();
$row_count = $query->rowCount();

尝试从数据库中做一个简单的用户名和密码检查..我已经超出了沮丧的地步......

最佳答案

改用 prepare。

$username = $_POST['username']; 
$password = $_POST['password'];

$db = new PDO('mysql:host='.$DB_HOST.';dbname='.$DB_DATABASE.'', ''.$DB_USER.'', ''.$DB_PASSWORD.'');

$query = "SELECT * FROM login_details WHERE username=:username AND password=:password";
$statement = $db->prepare($query);
$statement->bindValue(':username', $username, PDO::PARAM_STR);
$statement->bindValue(':password', $password, PDO::PARAM_STR);


$statement->execute();
$row_count = $statement->rowCount();

echo $row_count;

更多信息 here .

关于php - 非静态方法 PDO::quote() 不能静态调用,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39298161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com