为什么这可以在我的服务器上运行,但不能在我的学校上运行?
我刚刚创建了一个验证码,它在我自己的服务器上完美运行。在学校的服务器上,它不会生成图像。为什么会这样?代码的差异是一行。
编辑:本来它是可以工作的,但是我错误地删除了该目录,我不知道为什么它突然就可以工作了。
更新:我var_dumped()
一切都设置正确。 学校服务器上的源代码:
更新:我想通了!我稍后会发布答案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保您学校的服务器中启用了 GD 库。
还可以尝试将这些行放在脚本顶部以查看是否有任何错误:
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:
将此类问题直接问 SO 是没有用的。
一定有成千上万个原因。
当然,如果无法访问您的服务器和环境,没有人可以仅通过查看工作代码来判断。
唯一能回答这个问题的人就是你自己。
当然,在您的服务器的帮助下。
您必须向服务器询问错误。
但有时(例如,在解析错误的情况下)这不起作用。在这种情况下,您必须通过 .htaccess 设置这些参数或检查网络服务器的错误日志。
另外,你必须做某事。
至少在脚本中添加一些文本输出以确保其被执行。
使用 var_dump() 打印出变量以确保包含正确的值。
添加故意错误以确保您可以看到它们(如果有)。
做点什么,不要坐着看代码!
有关如何帮助自己的更多信息:http://www.ibm.com/ developerworks/library/os-debug/
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.
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/