PDA

View Full Version : script problem


0810
10-19-2002, 06:02 AM
hi how are you doing? What I am trying is to do is that I try to take mypicture, link, comment from my database randomly. But I got an error

Here it is

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in c:\ito\kkk.php on line 17



my php is 4.22. Thank you very much
here is my code

$images[]=array("pic"=>$row['pic']);
}

for ($i = 0; $i < 1; $i++)
{
$count=count($images)-1;
$pick=rand(0,$count);

echo "<a href=\"".$image[$pick]["link"]."\"><img src=\"".$images[$pick]["pic"]."\" border=0 alt=\"\" $images[$pick]["comment"]."\" width=200 height=200 style=\"margin-left:100;\". ><br>\n";


}

brothercake
10-19-2002, 08:22 AM
It's a syntax error

alt=\"\" $images[$pick]["comment"].""

should be

alt=\"".$images[$pick]["comment"]."\"

0810
10-19-2002, 05:33 PM
I got picture only from my database.

I don't get link and comments from my detabase.

Here is my error again


Notice: Undefined variable: image in c:\ito\kkk.php on line 17

Notice: Undefined index: comment in c:\ito\kkk.php on line 17


Could you help me

Ökii
10-19-2002, 08:45 PM
Unless you have a variable named image AND a variable named images, I guess the first parse error is because one hasn't got the s on the end.
Undefined index means exactly that - that the variable array images[pick] doesn't have an index named 'comment'