Jump to content

[SOLVED] Parse error


[n3rve]

Recommended Posts

<?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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.