Why might this work on my server but not my schools?

折月煮酒 提交于 2019-12-25 03:15:11

问题


I created a captcha just now, and it works PERFECTLY on my own server. On the school's server, it doesn't generate an image. Why might this be? The difference in code is one line.

Edit: Originally, it was working, but I deleted the directory by mistake and I do not know why did it suddenly work in the first place.

Update: I var_dumped() everything and everything is being set correctly. Source code on school server:

Update: I figured it out! I'll post the answer later.


回答1:


It is just useless to direct such kind of questions to SO.
There must be thousands of reasons.
And, of course, without access to your server and environment, nobody can say, just by looking into working code.

The only person who can answer this question is you yourself.
With help of your server, of course.
You must ask your server for errors.

ini_set('display_errors',1);
error_reporting(E_ALL);

but sometimes (in case of parse errors for example) this won't work. In this case you have to either set these params via .htaccess or check web-server's error log.

Also, you have to do something.
At least add some text output in the script to be sure it being executed.
print out variables using var_dump() to ensure thy contain right values. Add an intentional error to ensure you CAN see them if any. Do something, don't sit watching code!

Some more info on how to help yourself: http://www.ibm.com/developerworks/library/os-debug/




回答2:


Make sure that GD library is enabled in your school's server.

Also try putting these lines on top of your script to see if there are any errors:

ini_set('display_errors', true);
error_reporting(E_ALL);


来源:https://stackoverflow.com/questions/2864034/why-might-this-work-on-my-server-but-not-my-schools

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!