I am trying to install the database for my project with this file - install.php Code Below:
<?php
/*
** Open a connection with the database via PDO to create a new database and
tables with structure & insert initial values.
*/
require "config.php"
/*
** CREATING DATABASE CONNECTION**
*/
try{
$conn = new PDO("mysql:host=$host", $username, $password, $options);
$sql = file_get_contents("data/init.sql");
$conn->exec($sql);
echo "Databse and Tables created successfully. :)";
}catch(PDOException $error){
echo $sql."<br>".$error->getMessage();
}
?>
If I remove the try...catch implementation. Then it shows error unexpected $conn.
Has this anything to do with the PDO object creation. Wouldn't PDO run with
PHP 5.6.35. I am using WAMP 3.0.