手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆

PHP常见错误(二)

首页 > PHP >

mySQL Result Source Errors
mySql 资源错误
Warning: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in…
You need to take a look at the $result variable used to define the loop. More than likely there is a syntax error on the reported line before the $result field, or the value of $result does not exist.
通常,在进行msyql_query后,你需要对取得的数据进行遍历,如果出现上面错误时,你得检查一下你的$result是否是一个resource,这种情况在SQL查询语句错误(但错误没有被抛出)的情况下,所以,发现此问题时,可以考虑打印出SQL,到PHPMYDMIN里执行一下看看是怎么回事。

Supplied argument is not a valid stream resource…
This is usually caused when your code is looking for a table or other resource in the database that does not exist.
这个问题的情况通常是你代码中指定的表或者资源不存在于该数据库

Sessions are not being created or maintained
Sessions 不能被创建或者被修改维护
This can apply to any of the scenarios below:
这可能会出现以下几种情况
(1) The program isn’t remembering your login 程序没有记录下你的登录状态
(2) Your shopping cart won’t hold items 你的购物车没有保持你的商品状态
(3) Your php script is redirecting like crazy 你的PHP代码跳转的太疯狂
(4) “Call undefined function session_start” error 你的服务器没有打开Session功能
(5) PHP isn’t processing pages called by something like index.php?page=home&id=7 你的PHP代码不能打开某个页面,比如index.php?page=home&id=7

Your site is most likely dependent on register_globals. You can enable them by putting this line in your .htaccess (or just enabling in your php.ini if you have access):
你的网站可能会依赖register_globals(全局变量)打开。你可以将下面这行加到你的.htaccess文件里(当然,如果你有权限更改PHP.ini,还是改php.ini更方便)
php_flag register_globals On

Stream Errors
文件流错误
Warning: failed to open stream…
Warning: main(/index.php): failed to open stream: No such file or directory in…

This is usually because either the specified file is missing, or a file declared in a require() or include() function is missing. The easiest way to fix this is by re-installing the PHP program from a freshly-uploaded copy, or restoring the original config.php and just changing the db information. The include path may also be incorrect, but either way your script is looking for a file that isn’t there, or it is looking in the wrong place.
这两个问题的出现,通常是文件没有找到或者文件不能被require和include。(上面的英文我觉得不太准,个人认为应该是:先检查一下文件是否确实存在,检查文件的路径,当然,还得看一下php.ini的include_path,如果这些都检查过了。那么尝试用绝对路径加载文件)

Warning: fopen(…): failed to open stream: Permission denied in…
This is a permissions and/or ownership issue. Try first setting the permissions to 777 just to see if the script will run. If so, you should narrow down the permissions to 775. If not, set the user/group to user:nobody.
文件没有权限被读取,如果你想要你的文件被读取,设置文件权限为775,如果该文件需要被执行,那么就设置成777。否则设置用户权限/组为:nobody

Warning: <…> is not a valid stream resource…
Warning: fread(): supplied argument is not a valid stream resource in…
This is an error seen when trying to use functions like fopen(), fread(), feof(), etc. and are usually caused by an invalid or unavailable resource that is being called in the line specified. For instance, if the fread() function is returning this error, it could be that the file it is trying to access does not have the correct permissions or does not exist.
这也是一个常见错误,当你使用fopen(), fread(), feof()等函数时,就可能会出现,错误原因一般是fopen()或者其他函数打开文件失败,但错误信息被屏蔽,如$fp=@fopen('file.txt');,在这种情况下,再使用fread()读取时,就会出现上面的出错信息。

Warning: Failed opening….
Warning: Failed opening ‘…’ for inclusion (include_path=’.:/usr/local/lib/php’) in Unknown on line 0
Make the sure that the file mentioned (and its holding directorie) has read + execute permissions, and that the path to the file is correct. If not, you’ll need to add the path into the PHP code: (or .htaccess)
请确认文件是否有读写权限并且路径是正确的。如果不是,你需要把路径加载到你的PHP代码或者.htaccess文件里

include(”/path/to/files”);
Blank PHP Pages

You go to a .php page, but it’s blank.
The scope of what can cause blank pages is very broad, but there are a few things to look at:
-Is error reporting turned off anywhere in the script or in the .htaccess? If so, turn it on to see what is happening (php_flag display_errors on), or add the lines at the top of this page into the script.
-Is the PHP script even generating any output (usually you can tell my finding the print function?
-Check the database connection, i.e, username, dbname, user added to db, etc.
-Try using the full <?PHP ?> tags, rather than the shorter versions <? ?>
当你转向到a.php的页面时,但是打开的却是空白页面,出现这种问题的原因有很多,这里只介绍一些让你尝试着解决一下:
1、错误报告是否关闭了?如果是,请打开错误报告,并且在你的这个文件里加上一些输出试试
2、是否PHP代码本身就是一个输出页面,试着寻找一下print之类的函数?
3、检查数据库连接,例如,用户名密码等
4、试着用完整的PHP标签:<?php?>,而尽量少用短标签<??>


Also, if the software is prebundled (like phpBB or Gallery), then the index or one of the include pages could be corrupted. Usually you can just replace the problem page with a working version from another installation.
有时,一些软件的测试版本中往往都会存在着一个错误或者BUG等,你可以试着将出错页用该程序的其他版本来替换掉。象(phpBB或者Ballery)


Max Execution Time Error
最大执行时间错误
You receive some variant of a “Max_execution_time” error when loading a page.
This is caused when a PHP script takes longer to execute than the server allows, but can be adjusted by adding a PHP directive to your .htaccess: (in seconds, 0 = unlimited) or modifying the value in php.ini.
php_value max_execution_time 0
打开页面时,显示 "Max_execution_time" 执行时间错误。
这应该是你的PHP代码在运行的时候,超过了服务器所允许的时候,但是,这是可以通过修改.htaccess或者php.ini来进行修改(0代表了不限制)
php_value max_execution_time 0


Open_basedir Errors

Warning: Unknown(): open_basedir restriction in effect.
This is a protective feature of Apache that restricts PHP from accessing files/folders outside the user’s home directory. Most of the time this is due to an incorrect include path in one or more of the config files (which are usually mentioned). Look for something like this:
/includes/somefile.php
/admin/files/anotherfile.php
The heading / tells the filesystem that these folders are on the server root, and thus prevents PHP from accessing them. You can usually fix this by changing the path to these files to be absolute to their location:
/home/username/public_html/includes/somefile.php
or
./includes/somefile.php
出现Open_basedir问题的时候,往往需要先检查,PHP_INI里面有没有设定open_basedir,如果PHP.ini里没有设定,还需要查看apache的http.conf的虚拟主机设定里,也否也进行了设置。如果设定了,还需要检查这些目录是否可读写,否则会出现受保护的错误。




本站采用创作共享版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"易栈网-膘叔", 保留原始链接, 此外还必须标注原文标题和链接.

Tags: php, error

« 上一篇 | 下一篇 »

只显示10条记录相关文章

使用PHP得到所有的HTTP请求头 (浏览: 63787, 评论: 3)
我为什么会选用phpstorm (浏览: 54025, 评论: 5)
快速生成目录树 (浏览: 47792, 评论: 7)
通过file_get_contents来Post数据的实例 (浏览: 47438, 评论: 5)
PHP导入导出Excel方法 (浏览: 46288, 评论: 3)
PHP的XSS攻击过滤函数 (浏览: 43839, 评论: 2)
PHP中Eval的作用 (浏览: 42643, 评论: 4)
超详细:在Mac OS X中配置Apache + PHP + MySQL (浏览: 42006, 评论: 1)
PHP sendmail (浏览: 38891, 评论: 7)
几个ZendStudio使用教程 (浏览: 37414, 评论: 0)

1条记录访客评论

不错。。

Post by QQ空间代码 on 2008, April 2, 9:18 PM 引用此文发表评论 #1


发表评论

评论内容 (必填):