我已经声明了一个 PDO,由于某种原因,脚本在声明它时停止了。它没有给我任何错误,只是由于某种原因而停止。我似乎无法深究。如果我做错了什么,请告诉我
<?php
// this function creates a PDO that can be used to connect to our mysql server
function getConnectionPDO($dbName){
if(!empty($dbName)){
$pdo = new PDO('mysql:host=localhost;port=8889;dbname='.$dbName,'root','root');
return $pdo;
}
else {
return null;
}
}
// gets login parameters
function getLogin($username,$password){
if(!empty($username) && !empty($password)){
$pass_hash1 = md5($password);
$pass_hash2 = md5($pass_hash1); // hashes the password twice
//creating connection
$pdo = getConnectionPDO('User_Data');
if($pdo != null){
$query_string = 'SELECT * FROM users WHERE username=:username AND password=:password';
$prepare = $pdo->prepare($query_string); // preparing for query
// binding parameters
$prepare->bindParam(':username', $username);
$prepare->bindParam(':password', $pass_hash2);
// testing if query passed successfully
$columns = $prepare->fetchColumn();
if($columns == 1){
return true;
}
else {
return false;
}
}
else {
return false;
}
}
}
?>
提前感谢您的帮助=)