我是一个完整的php初学者,所以问题是我猜的很明显,但到目前为止我无法在任何地方找到我的解决方案。我正在创建一个连接到MySQL数据库的登录框。当我尝试从所选列中为ID分配ID时,不会分配任何内容。建议为什么?
$dbh = new PDO("mysql:host=$mysql_hostname;dbname=$mysql_dbname", $mysql_username, $mysql_password);
/*** $message = a message saying we have connected ***/
/*** set the error mode to excptions ***/
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*** prepare the select statement ***/
$stmt = $dbh->prepare("SELECT email, password, ID FROM sta402_users
WHERE email = :email AND password = :password");
/*** bind the parameters ***/
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
$stmt->bindParam(':password', $password, PDO::PARAM_STR, 40);
/*** execute the prepared statement ***/
$stmt->execute();
/*** check for a result ***/
$ID = $stmt->fetchColumn(2);
/*** if we have no result then fail boat ***/
if($ID == false)
{
$message = 'Login Failed';
}
我一直收到登录失败的消息..