php - 使用 EasyPHP 时出现 PEAR "DB.php"错误

标签 php mysql pear easyphp

使用 EasyPHP 我发现了一个恼人的错误,我似乎无法修复。我在互联网上进行了搜索,得到了一些点击率,但我从这些博客文章和页面中一无所获。

PHP 和 Apache 工作正常,但是当我想将 MySQL 与 PEAR(包含在 EasyPHP 中)一起使用时,并且当我 require("DB.php") 时,我收到此错误:

Warning: require(DB.php) [function.require]: failed to open stream: No such file or directory in G:\Server\EasyPHP-5.3.3\www\tester.php on line 2

Fatal error: require() [function.require]: Failed opening required 'DB.php' (include_path='.;C:\php5\pear') in G:\Server\EasyPHP-5.3.3\www\tester.php on line 2

我的 PHP 脚本如下所示(它只是一个测试程序):

<?php
require "DB.php";
$db = DB::connect('mysql://root@localhost');
if (DB::isError($db)) { die("Can't connect:" . $db->getMessage()); }
?>

我尝试将“DB.php”的路径更改为EasyPHP的“PHP”文件夹和“Php\PEAR”以及各种奇怪的东西,但似乎没有任何作用;我收到相同的错误,但错误消息的第一行路径不同。

根据this page这个错误是由一些 phar 事情没有得到 pharred 或类似的东西引起的 - 我不明白这些,也不明白 the page 上提到的解决方法 .

解决方法如下:

Run the distributed phar with php -d phar.require_hash=0 go-pear.phar

如果你问我的话,这完全没有意义:) 另一种选择是“下载 go-pear 的 this non-pharred version 并使用它。”开始有意义了,但是我该怎么处理 go-pear 的东西呢?

我尝试了第一个解决方法,尽管我不太理解它。我打开 CMD,它默认显示:C:\Users\Lasse>(Lasse 是我的名字)

我尝试打开包含 go-pear.phar 的文件夹。这是结果:

C:\Users\Lasse>cd G:\Server\EasyPHP-5.3.3\php\PEAR //*hit enter*

C:\Users\Lasse> //this was shown, typed content of the line below this
C:\Users\Lasse>php -d phar.require_hash=0 go-pear.phar //*hit enter*
'php' was not recogninzed as an intern or extern command, a program or a batchfile.

C:\Users\Lasse>

我无法编辑 C:\Users\Lasse>> 前面的内容。每次我输入不返回错误的命令(即上面示例的第一行)时,都会显示一个双换行符,后跟默认的 C:\Users\Lasse>

这可能会让你们中的许多人感到惊讶,但当谈到数据库和 PEAR 时,我完全是一个菜鸟(自嘲的高五)。另外,我刚刚安装了 EasyPHP,所以请不要太苛刻。

另外...根据phpMyAdmin(也包含在EasyPHP中),我的MySQL版本是5.x(x的意思是我不记得了)。这是否意味着我必须使用'mysqli://root@localhost'

最佳答案

您无法在 Windows 中将 cd 切换到其他驱动器。做:

 g:
 cd Server\EasyPHP-5.3.3\php\PEAR

关于php - 使用 EasyPHP 时出现 PEAR "DB.php"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3588317/

相关文章:

mysql - 如何获取在SQL中从图书馆借出最多书籍的读者ID?

php - 从 mysql 更新到 PDO 的最佳实践

mysql - 检查 mySQL 表中是否存在重复条目

php - Composer 安装 pear 包

php - 取消注释 php.ini 后,XAMPP 和 cURL 无法正常工作

php - 带有MySql数据库的动态PHP网站;如何为此创建站点地图?

php - 警告 : mysql_connect() [function. mysql-connect]:无法连接到 MySQL 服务器

php - Markdown 中的自动命名 anchor

php - 比较 PHP 中的字符串,如果它们相似,则从数组中删除其中一个

php - 使用 PHP 解析 .htaccess 文件