msaz87 Posted February 1, 2007 Share Posted February 1, 2007 I'm trying to get a php script to run on a private server ... problem is it won't work. I had been testing the script on a public server and it works fine there. I ran a php info script to see the differences in the servers and go the following: Good Server: php 4.4.4 apache 1.3.7 Bad Server: php 5.1.4 apache 2.2 Here's the script: <? define('SERVER_ROOT','/home/XXXX/public_html/'); // Server path to domainname define('WEB_PATH','rotate/birthdays/'); // Path to images under domainname // In the above example, http://www.domain.com/ would use files // located on the server in /home/httpd/html and the images to // be called by this script are at http://www.domain.com/pics/staff $files = array(); $d = dir(SERVER_ROOT . WEB_PATH); while (($filename = $d->read()) !== false) if (substr($filename,-4)=='.jpg') $files[] = $filename; $d->close(); if (count($files)<1) die ('No Images Found'); // Seed Random Number list($usec,$sec) = explode(' ', microtime()); srand((float) $sec + ((float) $usec * 100000)); $imgnum = rand(1,count($files)); if (isset($files[0])) $file2use = $files[$imgnum-1]; else $file2use = $files[$imgnum]; // START GET DISPLAY NAME // filename (no path) is in $file2use $dispname = substr($file2use,0,-4); // Gets rid of the .jpg extension $dispname = str_replace('_',' ',$dispname); // Converts underscores to spaces $dispname = ucwords(strtolower($dispname)); // Make sure names are capitolized // END GET DISPLAY NAME // Displayed name is in $dispname $imgpath = WEB_PATH . "/" . $file2use; ?> When configuring the script for the public server ... I entered the wrong server root, but received an error. On the bad server, I receive no such error -- ever. I was just wondering if anyone could tell me if this is some kind of compatibility issue or not -- and if so, what I could do about it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/ Share on other sites More sharing options...
bibby Posted February 1, 2007 Share Posted February 1, 2007 Both Apache and PHP are backwards compatible, so I doubt that it's that. When I move files from server to server, sometimes they lose their read permission. chmod 644 those files , if they aren't already. A lot of times after scp, mine could be 700. -- What do you mean by "won't work". Forbidden error? no images? What about read permission to dir rotate/birthdays ? (each digit >= 5 ?) Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/#findComment-174403 Share on other sites More sharing options...
hvle Posted February 1, 2007 Share Posted February 1, 2007 There are things work in php4 and would not work on php5, but your code did not user any of those. my suggestion is post the error along with the line number so other people can spot problem quicker. for backward incompatibility on php5, go here: http://usphp.com/manual/en/migration5.incompatible.php Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/#findComment-174404 Share on other sites More sharing options...
msaz87 Posted February 1, 2007 Author Share Posted February 1, 2007 Let me explain a bit more... The private server is actually one hosted at the business I'm making this site for. Thing is, since it's private and on their network, I have to log into it using a client, so it's not traditional FTP. I checked permissions and they allow for everything, so I don't think that's the problem. When I say it doesn't work, I mean nothing happens. This is the script when it works: http://www.foothillsbaptist.org/r_test.php But on the private server I simply get a blank page... as in literally nothing when you check the source code. Because of this, I have no idea where it's having issues. Everything is set up the same, same code, same directory structure, etc. Hopefully that might make more sense... I appreciate your help. Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/#findComment-174411 Share on other sites More sharing options...
bibby Posted February 1, 2007 Share Posted February 1, 2007 ah, ok. I have a server that does that too. Do you have shell acces? php -l file.php You may be able to get error msgs this way. Also, try kicking that error reporting back on. Add this to the very top of your script. ini_set('display_errors', 1); error_reporting(E_ERROR | E_WARNING | E_PARSE); That wouldn't be a Plesk server, would it? I hate those boxes Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/#findComment-174417 Share on other sites More sharing options...
hvle Posted February 1, 2007 Share Posted February 1, 2007 what I would do is add a catch: if (($d = dir(SERVER_ROOT . WEB_PATH)) === false) { die ("can not read from directory"); } Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/#findComment-174420 Share on other sites More sharing options...
msaz87 Posted February 1, 2007 Author Share Posted February 1, 2007 I'm not sure why, but adding that piece of code from bibby did the trick. I don't know if that was supposed to solve the issue or not -- or maybe I had altered the code earlier and only thought I tested it. Either way -- I really appreciate all of your help. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/36608-compatibility-issue/#findComment-174431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.