Jump to content

Compatibility Issue


msaz87

Recommended Posts

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.

Link to comment
Share on other sites

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 ?)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.