今天下午试着把用PHP编写的经济学院新版网站上传到中南民族大学的服务器上,本来以为一切就OK了,没想到运行时遇到一大堆的错误提示。
例如:
Notice: Undefined index: delete in /home/economics/public_html/new/admin/news.php on line 22
Notice: Undefined variable: pagehome in /home/economics/public_html/new/admin/news.php on line 548
找到错误提示对应的代码行,$sort=$HTTP_GET_VARS["delete"];,代码书写没错,只不过取得的变量值是空值,因为我将许多功能集成在一个PHP文件中,在实现其它功能时才从表单给它赋值。
思考了一下原因,我是在Windows+Apache2.0.52 (WINNT)+PHP5.0.0和Windows+IIS6.0+PHP5.0.0环境下编写、调试网站PHP程序的,而学校的服务器是Fedora Core(Linux)+Apache/2.0.52 (Fedora)+PHP4.3.9,不同版本不同运行环境下的PHP兼容性不好。试着在Fedora Core的前身Red Hat Linux 9的环境下运行经济学院网站的PHP程序,也没问题。看来就是学校服务器上的那个该死的Fedora Core惹的祸了。
在网上寻找对策,一个解决方案是:“由于变量未定义引起的,打开php.ini,将;error_reporting = E_ALL & ~E_NOTICE前的分号去掉;如果你想关闭任何错误提示,打开php.ini,找到display_errors,设置为display_errors = Off,以后任何错误都不会提示。”但是我不可能去改学校服务器的php.ini配置吧,这个方案被我否定了。
看来我只好从我的程序本身下手了,把类似$sort=$HTTP_GET_VARS["delete"];的换成if(isset($HTTP_GET_VARS["delete"])){$sort=$HTTP_GET_VARS["delete"];},作个判断,如果delete传递过来的表单值不为空,才执行后面获取表单值的语句。但在修改过程中发现,这种方法太麻烦,效果也不是很理想。突然,在PHP手册中搜索到函数error_reporting(0);官方解释是Turn off all error reporting,于是把error_reporting(0);加到PHP程序的首行,运行后果然没出现任何错误提示,终于解决了这个难题。
例如:
Notice: Undefined index: delete in /home/economics/public_html/new/admin/news.php on line 22
Notice: Undefined variable: pagehome in /home/economics/public_html/new/admin/news.php on line 548
找到错误提示对应的代码行,$sort=$HTTP_GET_VARS["delete"];,代码书写没错,只不过取得的变量值是空值,因为我将许多功能集成在一个PHP文件中,在实现其它功能时才从表单给它赋值。
思考了一下原因,我是在Windows+Apache2.0.52 (WINNT)+PHP5.0.0和Windows+IIS6.0+PHP5.0.0环境下编写、调试网站PHP程序的,而学校的服务器是Fedora Core(Linux)+Apache/2.0.52 (Fedora)+PHP4.3.9,不同版本不同运行环境下的PHP兼容性不好。试着在Fedora Core的前身Red Hat Linux 9的环境下运行经济学院网站的PHP程序,也没问题。看来就是学校服务器上的那个该死的Fedora Core惹的祸了。
在网上寻找对策,一个解决方案是:“由于变量未定义引起的,打开php.ini,将;error_reporting = E_ALL & ~E_NOTICE前的分号去掉;如果你想关闭任何错误提示,打开php.ini,找到display_errors,设置为display_errors = Off,以后任何错误都不会提示。”但是我不可能去改学校服务器的php.ini配置吧,这个方案被我否定了。
看来我只好从我的程序本身下手了,把类似$sort=$HTTP_GET_VARS["delete"];的换成if(isset($HTTP_GET_VARS["delete"])){$sort=$HTTP_GET_VARS["delete"];},作个判断,如果delete传递过来的表单值不为空,才执行后面获取表单值的语句。但在修改过程中发现,这种方法太麻烦,效果也不是很理想。突然,在PHP手册中搜索到函数error_reporting(0);官方解释是Turn off all error reporting,于是把error_reporting(0);加到PHP程序的首行,运行后果然没出现任何错误提示,终于解决了这个难题。
小子
2011-5-4 11:42
你好,现在争论一个问题,我朋友说你的这个方法存在着安全的问题,我想问一下??
louis vuitton uk
2011-11-22 17:21
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
armani watches
2011-11-23 10:21
If you are looking for armani Bags, our armani watches Handbags Canada outlet store is your first choice. We promise Original Packing and Best Discount,3-5 Workdays To Your Door!If you buy bags and purses of the latest new designs from the louis vuitton outlet now, you can enjoy special discounts. What else are you waiting for?After you choose the right kind of plants and the size pot for the plant.
分页: 1/1
1
1
生活并不需要无谓的执着[原创]
部分PHP问题总结[转贴]

2005-6-2 23:01 | by




![订阅回忆未来[张宴]的博客](http://pic1.s135.com/images/rewin/rss.gif)




