Husni AL-Fikri Dalimunthe Husni AL-Fikri Dalimunthe - 1 year ago 147
PHP Question

Undefined property: PDOStatement::,$id_login,$nama_depan


Include '../../konfig/conn.php';
echo $id=$_SESSION['id'];

$sql="SELECT*FROM i_user WHERE id_login=$id";

I'm Try to count data from database and it's working

echo "<br>".$stmt->rowCount()." Total Rows";

and the result is "1 Total Rows", Please help me to fixed this...

echo $stmt->id_login;
echo $stmt->nama_depan;
return $stmt;

and this picture
from my database php code

Answer Source

Perhaps like this?

while($rs = $stmt->fetch(PDO::FETCH_LAZY)){
    echo $rs->id_login;
    echo $rs->nama_depan;

Or, using prepared statement with a bound variable

include '../../konfig/conn.php';

$sql="SELECT * FROM i_user WHERE id_login=:id";

$stmt=$conn->prepare( $sql );
if( $stmt ){
    $res = $stmt->execute();
    if( $res ){
        while( $rs=$stmt->fetch( PDO::FETCH_LAZY ) ){
            echo $rs->id_login, $rs->nama_depan;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download