I am following the Jump Start PHP book from sitepoint and I am trying to input user details into a table called “user” in my database called “kickstartapp”
This is the PHP code that I have copied exactly from the book. I run the code in my browser but upon checking the phpMyAdmin there are no details in the “users” table.
<?php
$db = new PDO("mysql:host=localhost; dbname=kickstartapp", "USERNAME", "PASSWORD");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$queryStr = "INSERT INTO users (username, password, email) VALUES ('admin', MD5('admin'), 'youremail@domain.com')";
$db->query($queryStr);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
Could anyone tell me the reason why please?
Thanks in advance