0
    //This is my function in retrieving the id of the user base from its email and pass. this is for functions.php 
       function getID($email,$pass)
        {
                $pdo = new PDO(connection here);
            $stmt = $pdo->prepare('SELECT id user where email = :email and pass = :pass LIMIT 1');
            $stmt->execute(array(':email'=>$email, ':pass'=>md5($pass)));
            $result = $stmt->fetch();
            return $result['id'];//Is this the right way of returning a value from a fetch value?
        }
//this is for user.php. 
include 'function.php';
session_start();
$_SESSION['id'] = getID($_POST['email'],$_POST['pass']);

这是检索它的正确方法吗?但我没有从中得到任何价值。需要帮助谢谢!

4

1 回答 1

0

您的查询缺少FROM.

SELECT id FROM user WHERE email = :email AND pass = :pass LIMIT 1

于 2012-08-22T00:35:34.570 回答