使用 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/