I have this problem I can't figure out, I query the DB this way:
$stmt = $this->pdo->prepare('SELECT customer_name FROM active_users WHERE a_id= ?');
$stmt->execute(array($a_id));
$c_name = $stmt->fetch(PDO::FETCH_OBJ);
API::writeToLog('CMD=leave , Customer_Name = ' . $c_name->customer_name, $customer_name);
This: $c_name->customer_name gives the following error :
Notice: Trying to get property of non-object
How can I iterate my database, and whats the difference between fetch and fetchAll ? which should I use?
This is the DB schema:
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| a_id | varchar(40) | NO | PRI | NULL | |
| token | varchar(64) | NO | | NULL | |
| nick | varchar(255) | NO | | NULL | |
| ip | varchar(32) | NO | | NULL | |
| customer_name | varchar(255) | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
thanx!
EDIT: fixed a typo..