Code works in Development but not Production

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Code works in Development but not Production

Post by James0816 »

I am in a quandry here.

I have developed an Intranet application for my work place. I am using my machine as my development machine. I have an identical machine for production.

On the dev side of things everything works perfectly. I copied the code from the dev machine to production. For some reason, on the production side of things, my uploading of files is not working for .tif files. I can upload every kind of other files and to different folders, just not these files. And they are relatively small at max of 2.5mb. It works fine from my (dev) machine. I have checked the source code for any possible machine dependant code (all the same), I have checked the PHP.ini file on both machines...all the same.

I'm not sure if this is enough to go by to help, but I could really use some to figure it out.

Can anyone possible shed a little light on this for me? I will glady supply as much information as I possibly can.

Thank you very much!

:banghead:
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

Hey James,

I know you said that you checked the php.ini and they are identical, but I would just take one more look at the configuration in your production environment, specifically these two directives:

upload_max_filesize (http://php.net/ini.core#ini.upload-max-filesize)
post_max_size (http://php.net/ini.core#ini.post-max-size)

PHP deafults to 2MB for file uploads. Set them both to an adjusted value (like 8M, actually post_max_size should be slightly larger than whatever you set upload_max_filesize to, check the docs) or whatever you feel is reasonable to get the job done. Let me know how it goes.

Also, try to check the values using phpinfo(); to make sure your adjustments are being reflected correctly.
James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Re: Code works in Development but not Production

Post by James0816 »

Interesting ..... very interesting indeed.

I just check the PHP.ini on both machines:

post_max_size = 8M
upload_max_filesize = 10M

after reading your post, I went back to the production environment to test uploading of any file over 2mb. Did not work. Anything under 2MB, I was able to upload just fine.

There must be another setting somewhere that I missed on the production side.
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

Can you describe the behavior that you see on your production server? What exactly happens when you try to upload? Also, did your phpinfo() dump show the same as what you have set in your php.ini?
James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Re: Code works in Development but not Production

Post by James0816 »

phpinfo does show the 8 and 10 mb respectively.

what happens is...when i try to upload a file that is over 2mb...the status bar at the bottom of the browswer keeps going and then i eventually get a blank browser window saying done.

files less than 2mb, it zips right though.
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

Thanks for the additional info. Do you have display_errors enabled in your php.ini file? You might also try checking your max_input_time directive to see what that's set to (http://us3.php.net/manual/en/info.confi ... input-time).

How long does it take for your 2MB file to upload? Have you tried checking your webserver logs to see if PHP is complaining about anything? The blank page bit seems like the PHP engine is giving up at some point. If it was a filesize issue I would expect it to just dump you back on your form.
James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Re: Code works in Development but not Production

Post by James0816 »

max_execution_time = 30
max_input_time = 60
memory_limit = 8M


Not sure on the log files. Where would I check for them?
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

Where your log files are kept will depend on what OS/Webserver you are using. If it's a linux box and you run apache, I would suspect /var/log/apache2, for windows I'm not sure. Was display_errors turned on already then?
James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Re: Code works in Development but not Production

Post by James0816 »

it was set to off. I changed it to ON as well set the log file to this:

error_log = c:/phplogfile.txt

do i have to reset the machine to re-initialize the php.ini file?
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

Unless you're running PHP as a cgi, then yes, the web server will need to be restarted. After restarting, try to upload your file again with display_errors on and see if it gives you any errors.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Code works in Development but not Production

Post by Benjamin »

First thing I would verify is that the upload folder is writable guys.

EDIT: Missed the part about other file types working, ignore me.
Last edited by Benjamin on Thu Jun 19, 2008 11:52 am, edited 1 time in total.
James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Re: Code works in Development but not Production

Post by James0816 »

Findings in log file:

[19-Jun-2008 12:33:28] PHP Fatal error: Maximum execution time of 60 seconds exceeded in

This is interesting because if I am interpretting this correctly, my php.ini file has the following value:

max_execution_time = 30


Why would it say 60 if it is supposed to be set to 30?
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

I -think- it's because max_execution_time and max_input_time get rolled up into the same thing. Just try cranking up the values and see if you still have the issue.
James0816
Forum Newbie
Posts: 10
Joined: Thu Jun 19, 2008 9:10 am

Re: Code works in Development but not Production

Post by James0816 »

I just tried the following values and got the same 60 second time out error:

max_execution_time = 180
max_input_time = 360
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Code works in Development but not Production

Post by nowaydown1 »

Sounds like for whatever reason your php.ini changes aren't being picked up. Try to dump phpinfo() again and see if it's still showing 60. I'm really in the dark when it comes to Windows configuration stuff. Maybe one of the other guys can chime in here.
Post Reply