Code has been added to clipboard!
MySQL Insert Into for PDO Users
Example
<?php
$servername = 'localhost';
$username = 'name_of_the_user';
$password = 'users_password';
$dbname = 'myDatabase';
try {Â Â Â
$conn = new PDO("mysql:host=$servername; dbname=$dbname", $username, $password);Â
// set the PDO error mode to exception  Â
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   $sql = "INSERT INTO MovieList (title, rating, price) VALUES ('random_movie', 'good', '5')";
  // use exec() because no results are returned
$conn->exec($sql);Â
echo "Inserted successfully";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();Â Â
}
$conn = null;
?>