php - Referencing to an associative array value from PDO::FETCH_ASSOC -


im having basic problem using pdo , need - chances have syntax error somewhere cant life of me find (im new pdo , havent used associative arrays focus on part of code!)

i selecting data database associated user email address using following code:

$id = 'email@address.com';   $stmt = $db->prepare('select * first_page email=?'); $stmt->bindvalue(1, $id, pdo::param_str); $stmt->execute(); $resulty = $stmt->fetchall(pdo::fetch_assoc);  print_r($resulty); echo $resulty['title']; 

the print_r displays associative array in entirety, echo doesnt show stored value column 'title'. there is column called 'title' in database, im presuming im referencing incorrectly. looks near identical example have in book in front of me dont know start looking!

the print_r output is:

array ( [0] => array ( [user_id] => 93 [time_stamp] => 2014-03-04 22:00:16 [title] => mr [first_name] => pete [surname] => john [phone] => 2147483647 [email] => email@address.com)) 

$stmt->fetchall() returns array of associative arrays, because supports returning more 1 row worth of data.

even if result set has 1 row, fetchall() still returns array of 1 element, associative array 1 row.

so need:

echo $resulty[0]['title']; 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -