Php


#1

My first attempt at doing some PHP was less successful than i had hoped…this should be an easy problem to diagnose.

i wanted to add to an existing HTML page a dynamic element, specifically a random photo from a folder of twelve identically sized .gif files. After uploading those files to a /random/ folder, i used a .PHP script located at http://hiveware.com/imagerotator.php which looked amazingly simple.

All i needed to do is change the “random image” folder path in the rotate.php file to read $folder = “/random/”;
(instead of the default), and then add a line of code to the original HTML page to include:

But it doesn’t work…the height, width and alt tags all work but the random image does not load. i even renamed the .HTML file being modified as a .PHP file - still no dice.

Any idea what i am doing wrong? If the 12 images are in a folder called www.bignoize.net/random/, is the path listed above for the random.php file correct?

Any help greatly appreciated =)

Cheers,

Paul@BigNoize.Net


#2

If a script is asking for a path (as opposed to a URL), it means the absolute path on the server - so if you set it to “/random/”, it’ll look for the directory “random” in the root of the server, and that doesn’t exist :slight_smile:

Try giving the complete path to your directory, most likely something like this:

/home/youruser/bignoize.net/random/


#3

[quote]If a script is asking for a path (as opposed to a URL), it means
the absolute path on the server - so if you set it to “/random/”,
it’ll look for the directory “random” in the root of the server, and
that doesn’t exist :slight_smile:

[/quote]

Usually, you can use relative paths as well, ie. “random/” would be a directory named ‘random’ in the same directory as the script.

  • Jeff @ DreamHost
  • DH Discussion Forum Admin