I'm doing a dynamic image and in it I have to include a file. to include I use

include("/blah/blah/blah/file.php");

and it works great on that server but when I try to post the picute on another server with the img tag in HTML it doesn't work because it is trying to go /blah/blah/blah/file.php on the server where the HTML is.... 😕

    check your path, try

    include("blah/blah/blah/file.php");

    or

    include("./blah/blah/blah/file.php");

      Hi

      I have a local network server, and four sites with the same script on. How I handle it is:

      1. Create a config file, such as myconfig.inc.php

      (This file you will need to locate accurately in each php file, so some editing is required).

      In that file do something like this:

      if ($_SERVER['DOCUMENT_ROOT']=="D:/Apache2/htdocs/My_Website")
      {
      //URL path for php files (NOT includes)
      	$docRoot="D:/Apache2/htdocs/My_Website";
      //root to css, images, html and java
      	$root_url="D:/Apache2/htdocs/My_Website";
      //roots to php files
      	$root_alturl="http://localhost:8080";
      }
      elseif ($_SERVER['DOCUMENT_ROOT']=="/home/server1user/public_html")
      {
      //URL path for php files (NOT includes)
      	$docRoot="/home/server1user/public_html";
      //root to css, images, html and java
      	$root_url="http://www.yourweb.com";
      //roots to php files
      	$root_alturl="http://www.yourweb.com";
      }
      

      Then use the variables as indicated. The $docRoot is used for URL references to links for php files, as external links often cause security issues (many server owners have banned the use of [url]http://www.*****.com[/url] links to php files when included or required, etc).

      Trevor

        Write a Reply...