It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

random picture

Moderator: Malcolm

random picture

Postby Phate on Thu Apr 21, 2005 3:33 am

I am using these codes to try and generate a random picture, but when i upload, all i get is a white screen...
any ideas?
Code: Select all
<?php

//generate random numbers
$start = "1";
$stop = "9";
$random = mt_rand($start, $stop);

?>


Code: Select all
<?php echo "<img src="/$random.jpg"> "; ?>
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby Malcolm on Sun Apr 24, 2005 12:47 pm

Try:
Code: Select all
<?php
$start = 1;
$stop = 9;
$random = mt_rand($start, $stop);
?>
...
<?php echo "<img src=\"".$random.jpg."\"> "; ?>
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby Phate on Sun Apr 24, 2005 2:55 pm

when I use that code... everything loads perfect, except for the picture itself... nothing comes up where the random image should be
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby webmaster on Sun Apr 24, 2005 4:04 pm

It should be:
Code: Select all
<?php echo "<img src=\"".$random.".jpg\"> "; ?>
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Phate on Sun Apr 24, 2005 7:13 pm

sweet!!
webmaster that code worked!


thanks guys!!
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1


Who is online

Users browsing this forum: No registered users and 2 guests