我已经搜索了很长一段时间,但没有运气。我想检查一个给定的用户名和密码是否正确然后回应一些东西,但它不起作用。在此之后我想运行另一个查询。
<?php
require "conn.php";
$status=1;
$user_name = $_POST["user"];
$user_pass = $_POST["pass"];
$sql = "select * from tbl_client where username = :user and password = :pass";
$sth = $dbL->prepare($sql);
$sth->execute(array(':user => $user_name' , ':pass => $user_pass' ));
//$sth->execute(':user' => $user_name, ':pass' => $user_pass);
$row = $sth->fetch(PDO::FETCH_NUM);
if ($row) {
echo 'login success , Hello';
} else {
echo 'login failed';
}
$sql = 'insert into login_status (username, status) values (:user, :status)';
$sth = $dbL->prepare($sql);
$sth->execute(array(':user => $username' , ':status => $status' ));
?>
答案 0 :(得分:1)
$sth->execute(array(':user' => $username , ':pass' => $user_pass ));
这是完全错误的!您的数组包含2个字符串,其中应包含2个键值对(SQL查询中的key =参数,值=您要传递给数据库驱动程序的内容)
试试这个
<dimen name="name_dimen">20dp</dimen>