[n3rve] Posted November 17, 2009 Share Posted November 17, 2009 <?php error_reporting(E_ALL); // Avatar Script $img_dir = 'images/avatars/'; // location of avatars on the server $no_of_avatars = 2; // Total number of avatars in $img_dir for($avatar = $no_of_avatars; $avatar > 0; $avatar--) { $avatar_dir = 'images/avatars/avatar'.$avatar.'.gif'; echo "<img src=\"$avatar_dir\" /*alt=\"avatar ID: $avatar\"*/ /> "; } echo '<br />'; for($avatar = $no_of_avatars; $avatar > 0; $avatar--) { $avatar_dir .= ' .' $img_dir . $avatar '..gif'; echo "<img src=\"$avatar_dir\" /*alt=\"avatar ID: $avatar\"*/ /> "; } echo $avatar_dir; ?> Help, this is a little script I'm working on. Essentially, it looks into a directory for images and prints them to the browser provided they are dropped in the $avatar_dir and are named avatarX.gif where X falls under $no_of_avatars. The above script is just a bit of what I'm working on and I want to avoid users digging into the middle of the files to make changes so the script works on their servers so I want the variables that need to be edited at the top of the file. The problem is I can't figure out how to use $img_dir in $avatar_dir within the script and still have it work, I've been getting parse errors after trying different methods -[n3rve] Link to comment https://forums.phpfreaks.com/topic/181866-solved-parse-error/ Share on other sites More sharing options...
cags Posted November 17, 2009 Share Posted November 17, 2009 Sounds like you just want... $avatar_dir = $img_dir . 'avatar' . $avatar . '.gif'; ...or did I miss the point? Link to comment https://forums.phpfreaks.com/topic/181866-solved-parse-error/#findComment-959147 Share on other sites More sharing options...
[n3rve] Posted November 17, 2009 Author Share Posted November 17, 2009 No, you didn't miss the point, it works . <?php error_reporting(E_ALL); $img_dir = 'images/avatars/'; // location of avatars on the server $no_of_avatars = 2; // Total number of avatars in $img_dir for($avatar = $no_of_avatars; $avatar > 0; $avatar--) { //$avatar_dir = 'images/avatars/avatar'.$avatar.'.gif'; $avatar_dir = $img_dir . 'avatar' . $avatar . '.gif'; echo "<img src=\"$avatar_dir\" /*alt=\"avatar ID: $avatar\"*/ /> "; } echo '<br />'; ?> Topic marked as solved. -[n3rve] Link to comment https://forums.phpfreaks.com/topic/181866-solved-parse-error/#findComment-959155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.