php include_once() 错误

lwl0606 2009-07-28 10:57:13
php 程序出现如下错误
Warning: include_once(C:\Inetpub\wwwroot/securimage/securimage.php) [function.include-once]: failed to open stream: No such file or directory in D:\chineseloving\regcheck.php on line 43

Warning: include_once() [function.include]: Failed opening 'C:\Inetpub\wwwroot/securimage/securimage.php' for inclusion (include_path='.;C:\php5\pear') in D:\chineseloving\regcheck.php on line 43

Fatal error: Class 'Securimage' not found in D:\chineseloving\regcheck.php on line 45

我装的是IIS+PHP,虚拟目录指向D:\chineseloving,其他页面可以正常访问。
搞不懂为什么会C:\Inetpub\wwwroot/securimage/securimage.php这样的错。

该程序在bluehost 的linux服务器上可以正常访问。
本人新手,请问大家是什么原因。
谢谢。
...全文
685 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Gdj 2009-07-28
  • 打赏
  • 举报
回复
在php里路径\和/是通用的,应该不存在问题。
我想你如果能确定那文件是存在的话,你有访问权限吗?
tian428 2009-07-28
  • 打赏
  • 举报
回复
$_SERVER['DOCUMENT_ROOT'] 就是脚本所在的文档根目录

去看下web服务器的配置,DocumentRoot 这项

to 7楼,绝对路径就是以c:/这样盘符开头的路径(linux是/);相对路径 比如 ./s.php或s.php表示当前目录的s.php文件

to 8楼,不能改,给了就不能兼容linux了
程序猿之殇 2009-07-28
  • 打赏
  • 举报
回复
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
=>
include_once '/securimage/securimage.php';试试
程序猿之殇 2009-07-28
  • 打赏
  • 举报
回复
如果使用的站点是默认站点,$_SERVER['DOCUMENT_ROOT'则获取的根目录是: c:\inetpub\wwwroot
阿_布 2009-07-28
  • 打赏
  • 举报
回复
你把/改成\试试
lwl0606 2009-07-28
  • 打赏
  • 举报
回复
我觉得也是路径的问题
错误中所描述的
C:\Inetpub\wwwroot/securimage/securimage.php
应该是
D:\chineseloving\securimage\securimage.php

在PHP里面怎么写觉得路径和相对路径阿?
多谢
lwl0606 2009-07-28
  • 打赏
  • 举报
回复

if(!empty($_POST['reg_submit1'])){



include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

$securimage = new Securimage();

if ($securimage->check($_POST['captcha_code']) == false) {

// the code was incorrect

// handle the error accordingly with your other error checking



// or you can do something really basic like this

show_error("您输入的编码不正确。");

}

这是regcheck.php文件中39-59行的代码
llj480028 2009-07-28
  • 打赏
  • 举报
回复
我觉得应该用,相对路径吧!
tian428 2009-07-28
  • 打赏
  • 举报
回复
用的绝对路径?
请把代码给出
blueforyou 2009-07-28
  • 打赏
  • 举报
回复
分析你的错误,及linux下可以正常访问,得出一点可能的结论:
include_once里的路径是不是以"/"开头的?如果是的话,还是根据本文件相对路径找吧。
tfxg 2009-07-28
  • 打赏
  • 举报
回复
肯定是路徑問題
C:\Inetpub\wwwroot/securimage/securimage.php
C:\Inetpub\wwwroot/securimage/securimage.php
估計也沒有這樣的路徑吧,\和/要分清楚
程序猿之殇 2009-07-28
  • 打赏
  • 举报
回复
从错误信息来看,include_path为c:\php5\pear
你要包含securimage.php,绝对路径为C:\Inetpub\wwwroot/securimage/securimage.php

结果在这个路径下没有找到文件.
lwl0606 2009-07-28
  • 打赏
  • 举报
回复
最后用了个笨方法拷贝'/securimage/securimage.php' 到wwwroot下面。
多谢,各位,结贴
  • 打赏
  • 举报
回复
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

难道是权限问题?

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧