-3

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.

Rahul Hardy
  • 3
  • 1
  • 7

2 Answers2

2

use ; at end of line

require "config.php";
salari mameri
  • 228
  • 5
  • 13
  • 1
    When the answer is "add one missing semicolon", there is no need to answer. Just leave a comment under the question and flag/vote to close as Off-topic: Typo. This page will be quickly scrubbed from the site (as will any upvote points you receive) because this page is completely useless to researchers. – John Conde Jun 30 '18 at 13:11
0

You forgot a semicolon after require 'config.php'

Sebi Ilie
  • 86
  • 5
  • When the answer is "add one missing semicolon", there is no need to answer. Just leave a comment under the question and flag/vote to close as Off-topic: Typo. This page will be quickly scrubbed from the site (as will any upvote points you receive) because this page is completely useless to researchers. – John Conde Jun 30 '18 at 13:11
  • Can't leave comment to question unless 50 rep – Sebi Ilie Jun 30 '18 at 13:17