解析错误:语法错误,第 10 行 E:\wamp64\www\project-trial\install.php 中的意外“尝试”(T_TRY)

拉胡尔·哈迪

我正在尝试使用此文件为我的项目安装数据库 - install.php 代码如下:

<?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();
}
?>

如果我删除 try...catch 实现。然后它显示错误意外 $conn。这与 PDO 对象的创建有什么关系。PDO 不能与
PHP 5.6.35 一起运行我正在使用 WAMP 3.0。

萨拉里记忆

;在行尾使用

require "config.php";

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章