我正在尝试使用此文件为我的项目安装数据库 - 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] 删除。
我来说两句