Require() & GD Library

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rich

    #1

    Require() & GD Library

    I have 2 files... one that is very simple and only contains (for right
    now):

    <?php
    $fontcolor = "0,0,0";
    require("/home/rbrooks4/public_html/ticker/image.php");
    ?>

    image.php is a simple image creation via GD library. When I go to the
    first page, i get the generic image cannot be displayed because of
    errors. However if I go to image.php and paste the $fontcolor =
    "0,0,0"; line into the top of that file, the image displays. This says
    I have some funkiness with my require(). Is this just not possible to
    do? I don't understand what the difference is between the file pasted
    above, and pasting the one line on top of image.php.

    And yes, i took out the <? ?> tags of image.php when i used it as the
    require.

  • Jasper Bryant-Greene

    #2
    Re: Require() &amp; GD Library

    Then put the <?php ?> tags back in the require()d script because that's
    why it doesn't work. PHP scripts must always be delimited by <?php ?>
    tags even when they are require()d by another PHP script.

    Comment

    • rich

      #3
      Re: Require() &amp; GD Library

      errr yeah, yer right. I gotta start posting mid-day. That still didn't
      fix my problem tho... i'm getting the same error.

      Comment

      • Jasper Bryant-Greene

        #4
        Re: Require() &amp; GD Library

        Are you able to find out whether your PHP installation is running in
        safe_mode or an open_basedir restriction is in effect?

        If so it can sometimes help to use a relative rather than absolute path
        to the included file, like:

        <?php
        require('../ticker/image.php');
        ?>

        Or whatever the actual path is to your included file.

        Comment

        • rich

          #5
          Re: Require() &amp; GD Library

          Jasper Bryant-Greene wrote:[color=blue]
          > Are you able to find out whether your PHP installation is running in
          > safe_mode or an open_basedir restriction is in effect?[/color]

          Yeah, and no to both. Pretty sure that isn't it - I have other
          require/includes on other pages that use absolute path.

          Comment

          Working...