...

script problem

0810
10-17-2002, 05:29 AM
What I am doing is I try to put different three pictures whenever a user visits my site.

but it is not working yet

Here is an error message.

Parse error: parse error, unexpected T_VARIABLE in c:\ito\mypicture.php on line 11


Here is my script

<?php
$con=mysql_connect("localhost","itohideo",1234) or die("couldn't connect'");
$db=mysql_select_db("itohideo",$con) or die("couldn't select'");
$num_displayed=3;
$sql="select * from myimage limit $num_displayed";
$result=mysql_query($sql,$con)or die("couldn't excute");
while($row=mysql_fetch_array($result)){

$images[]=array("link"=>$row['link'],"mypic"=>$row['mypic'])
}
$count=$_POST["count"];
$pick=$_POST["pick"];

$count=count($images);
$pick=rand(0,$count);

echo "<a href=\"". $images[$pick]["link"]. "\"><img src=\"".$images[$pick]["mypic"]."\" border=0 alt=\""."\"><br>

?>

Spookster
10-17-2002, 07:42 AM
If all you are wanting to do is create a random image display then a database is really not needed. That will just slow things down. You can just put all the images in a directory and have php read the contents of the directory and randomly pick one of the images to display.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum