Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP code not working on a certain server

    Hi,

    I have the following code in my application and it is not working on a certain VPS server and I have no idea why.

    Server: Linux - PHP Version 5.3.16

    PHP Code:
    <?php
    define
    ('PROJECTS_DIR''../projects/');

    // Gets project names from the projects folder.
    function projects() {
    $projects glob(PROJECTS_DIR.'*'GLOB_ONLYDIR);
    for (
    $i=0$i<count($projects); $i++) {
    $projects[$i] = basename($projects[$i]);
    }
    return 
    $projects;
    }

    $projects projects();


    if (empty(
    $projects)) {
    echo 
    'No projects found.';
    }
    ?>

    The above code works fine on all other servers I tested but not on this one. No error, no output. What could be the reason? What should I check in phpinfo() or php.ini? Something to do with glob()?

    Thanks for any ideas.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Given what you have here, if you have no output than you successfully iterated the ../projects directory with the glob and returned matching subdirectories. The only time you'll have output is on an error.
    If there's more to it than this, than I'd suggest checking the HTML output to see if its a white page, or if it has PHP embedded within it. If it has PHP embedded, you simply don't have the server set up to process PHP code.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •