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 に答える