今天下午试着把用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程序的首行,运行后果然没出现任何错误提示,终于解决了这个难题。

Tags:



电脑杂谈 | 评论(28) | 引用(0) | 阅读(37502)
shz Email
2022-7-16 18:01
Thank you very much for sharing such a useful article. Will definitely saved and revisit your site  online scams
shz Email
2022-7-16 18:05
Very educating story, saved your site for hopes to read more!  online scams
shz Email
2022-7-16 18:07
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.  online scams
shz Email
2022-7-16 18:10
Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging,  online scams
shz Email
2022-7-16 18:14
I’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. nice one  online scams
hendy Email
2022-12-19 18:13
The article is very easy to understand, detailed and meticulous! I had a lot of harvest after watching this article from you! I find it interesting, your article gave me a new perspective! I have read many other articles on the same topic, but your article convinced me!  usps tracking number
jenxterai Email
2023-2-16 12:56
Discovering this page makes me happy. I want to thank you for your territorial io time and for this very excellent read. I have you set to my favorites to check at fresh material on your website. I absolutely liked every aspect of it.
Faith Morgan Email Homepage
2024-4-9 20:05
Absolutely thrilled with my refurbished phone! It's like finding a hidden tech treasure. Powerful device, amazing price, and the satisfaction of extending the life of a perfectly good gadget, helping the planet in the process.  Anyone else rocking a refurbished phone? Share your success stories and the fantastic deals you've found!  https://smartimobile.com
分页: 2/2 第一页 上页 1 2 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]