Calver Posted September 21, 2009 Share Posted September 21, 2009 Hello, I was very pleased to get a row of data from my database into an array, but I can't find out how to access it. This is what I get from: var_dump($this->row); array 0 => array 'id' => int 1 'firstname' => string 'Samuel' (length=6) 'lastname' => string 'Cross' (length=5) 'username' => string 'sammy' (length=5) 'password' => string '47bce5c74f589f4867dbd57e9ca9f808' (length=32) 'emailadd' => string 'sammy@somedomain' (length=16) 'about' => string '' (length=0) 'status' => int 1 'activationkey' => string '' (length=0) How do I retrieve a specific field, eg $firstname = ? Quote Link to comment Share on other sites More sharing options...
p2grace Posted September 21, 2009 Share Posted September 21, 2009 Use this method instead: $arr = mysql_fetch_assoc($query); $firstName= $arr['firstName']; http://us.php.net/manual/en/function.mysql-fetch-assoc.php Quote Link to comment Share on other sites More sharing options...
Alex Posted September 21, 2009 Share Posted September 21, 2009 echo $this->row['firstname']; // Samuel Quote Link to comment Share on other sites More sharing options...
Calver Posted September 21, 2009 Author Share Posted September 21, 2009 Use this method instead: $arr = mysql_fetch_assoc($query); $firstName= $arr['firstName']; Thank you, but I'm using mysqli with prepared statements. Sorry, I should have mentioned it. Quote Link to comment Share on other sites More sharing options...
Calver Posted September 21, 2009 Author Share Posted September 21, 2009 echo $this->row['firstname']; // Samuel My headache's starting to diminish already! It didn't work until I did this... echo $this->row[0]['firstname']; // Samuel Brilliant, thank you very much for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.