Simple variable problem with file name.

The problem is this. I generate a file name using a random number generator and this works find. Using echo the name of the file comes up just fine. But when I attempt to use that to call an image all I get is a blank image space.

The code is as follows

[code]<?php

function getdice()
{
srand(time());
$random = (rand()%6);
if ($random==0) $random=1;
return $random;
}

$imagestring= “die-” . getdice();
$newstring=$imagestring . “.gif”;

echo $newstring;

?>

X[/code]

The variable newstring is the file name. and if you go to the page you will see the file name is just fine. But the image does not come up. The images are in the same directory as the php page.

http://www.woodlandstar.net/Petals/PetalsStart.php

Thanks for help with this
Nevyn

I found the solution…that w3 school gets me into all kinds of trouble. After searching around the net the answer is to change the following:

<img src="<?php $newstring;?>" width="32" height="32" alt="X">

To:

<img src="<? echo $newstring?>" width="32" height="32" alt="X">

This works!

Sponsor our Newsletter | Privacy Policy | Terms of Service