Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname='localhost';
- $username='';
- $password='';
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=id6953396_infinity",$username,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- echo 'Connected to Database<br/>';
- $sql = "INSERT INTO students (student_name, student_email, student_city)
- VALUES ('Bob', 'bob@bob.bob', 'Bobdon')";
- if ($dbh->query($sql)) {
- echo "New record created successfully";
- }
- else{
- echo "Data not sucessfully inserted";
- }
- $dbh = null;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement