So just as I began to get a good grasp on MySQL, I found out I should be learning about PDO. This is the (unfinished) code I have so far. I'd like to get it working before worrying about adding more password security. When I run the script, the printed message is "Array". How can I break this down and retrieve the data in the array?
try {
$db = new PDO($dbhost, $dbuser, $dbpassword);
$statement = $db->prepare("select * from users where email = :name");
$statement->execute(array(':name' => $username));
$result = $statement->fetch();
echo $result;}
catch(PDOException $e) {echo $e->getMessage();}
Sorry if this is a silly question; I've been searching for a while, but can not find any good examples what match what I'm doing, and I learn better from examples than long, wordy descriptions (such as the PHP manual).
You might want to review your PHP base first, these pages seems most appropriate:
http://php.net/manual/en/language.types.array.php
Then, you can review again the code for Fetch and FetchAll at:
http://php.net/manual/en/pdostatement.fetch.php
Note that arrays are the defacto standard when receiving data from any provider, should it be pdo, mysql, mysqli, pgsql, this is why i recommend you review the ARRAY type first, get a good grasp of it, then read PDO stuff again...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.