pneudralics Posted March 12, 2006 Share Posted March 12, 2006 Got this from the random pic tutorial here. I'm getting Parse error: parse error, unexpected '\"', expecting ',' or ';' The following is line 23:echo "<img src="".$file_dir."/".$arry_txt[rand(0, sizeof($arry_txt) -1)]."">";So what went wrong? I'm still really new at php. Tried taking out the / and quotes, but nothing.[code]<?// #### RANDOM PIC ######################################### $thumbstring = ''; $file_dir="pics/a10"; // DIRECTORY WITH THE PICS $f_type="tm.jpg"; // FILE EXTENSION YOU WISH TO DISPLAY $dir=opendir($file_dir); while ($file=readdir($dir)) { if ($file != "." && $file != "..") { $extension=substr($file,-6); // THIS DIGIT MUST MATCH THE NUMBER OF CHARACTERS SPECIFIED IN THE FILE EXTENSION ABOVE if($extension == $f_type) { $thumbstring .= "$file|"; } } } srand((double)microtime()*1000000); $arry_txt = explode("|" , $thumbstring); echo "<img src="".$file_dir."/".$arry_txt[rand(0, sizeof($arry_txt) -1)]."">";// #### END RANDOM PIC #########################################?>[/code] Quote Link to comment Share on other sites More sharing options...
toplay Posted March 12, 2006 Share Posted March 12, 2006 Whatever character you start the string with, single or double quotes, that same character must be escaped if it's contained within that string.For more info, click the link below and find the answer to "Q: Is there another way of getting around escaping quotes all the time?"[a href=\"http://www.phpfreaks.com/forums/index.php?s=&showtopic=31047&view=findpost&p=153359\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=153359[/a] Quote Link to comment Share on other sites More sharing options...
pneudralics Posted March 12, 2006 Author Share Posted March 12, 2006 What do I need to add in if I didn't want mike.jpg to be displayed as a random image?Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.