I use PDO for my project, so i don’t know why my function return nothing…
function getuser($username) {
require 'database.php';
$rep = $bdd->prepare("SELECT * FROM membre where login =:user");
$rep =$bdd->execute(
array(
'user'=>$username
));
while($row = $rep->fetch(PDO::FETCH_OBJ)) {
//$userid = $row->id;
//$usermail = $row->email;
echo $row->id;
}
}
and usage:
$uname = $_SESSION['uname'];
echo $uname;
//result: kate
echo getuser($uname);
//result:
I don’t know Why it’s not work?
You have an error. Code should be:
Basically,
$repis astatement. Youprepare()a statement and then execute it. Right now you run execute on the wrong object.