$_SESSION['id'] = ( isset( $_SESSION['id'] ) ) ? $_SESSION['id'] : FALSE; $_SESSION['password'] = ( isset( $_SESSION['password'] ) ) ? $_SESSION['password'] : FALSE; $logged = mysql_query("SELECT * FROM `db_members` WHERE `id`='".$_SESSION['id']."' AND `password` = '".$_SESSION['password']."'"); $logged = mysql_fetch_array( $logged );
I tried solving the problem and the following works:
$_SESSION['id'] = ( isset( $_SESSION['id'] ) ) ? $_SESSION['id'] : FALSE; $_SESSION['password'] = ( isset( $_SESSION['password'] ) ) ? $_SESSION['password'] : FALSE; $sth = $dbh->query('SELECT * FROM `db_members` WHERE `id` = '.$_SESSION['id'].''); $sth->execute(); $logged = $sth->fetch(PDO::FETCH_OBJ); echo $logged ->id;
The problem is the code stops working, when I add the following:
AND `password` = '.$_SESSION['password'].'
I am not sure why is this happening.. are there restrictions for using AND in PDO? I looked online and there is hardly any help in this case. Please help, I really want to know whats the problem.. thanks
Edited by Vic Vance, 16 March 2012 - 10:11 AM.