I'm very new to php and am trying to fix code that was previously working.

Initially, i was getting an undefined error and changed code from:

function printChapter($committee){

	echo "<table width=\"99%\" border=\"0\" cellspacing=\"10\">\n";

	foreach($committee as $name => $c){
		
		$alt = $name;
		$names = explode(" ", $name);
		$fname = $names[0];
		
		$lname = "";
		for($i = 1; $i <= 3; $i++){
			$lname .= $names[$i];
		}

to:

function printChapter($committee){

	echo "<table width=\"99%\" border=\"0\" cellspacing=\"10\">\n";

	foreach($committee as $name => $c){
		
		$alt = $name;
		$names = explode(" ", $name);
		$fname = $names[0];
		
		$lname = "";
		for($i = 1; $i <= 3; $i++){
			$lname .= isset($names[$i]);
		}

Which stopped the undefined error....but now the images are not displaying at all...

<?php
function get($value)
{
	return isset($_GET[$value]) ? $_GET[$value] : null;
}

function post($value)
{
	return isset($_POST[$value]) ? $_POST[$value] : null;
}

function error($error)
{
	echo "<div id=\"error\">{$error}</div>\n";
}

function success($message)
{
	echo "<div id=\"success\">{$message}</div>\n";
}

function session($var)
{
	return $_SESSION[$var];
}

function allgroups()
{
	$link = connect();
	$query = "SELECT * FROM `groups`";
	select($query, $result_set, $link);
	$groups = array();
	$count = 0;
	while (($row = next_result($result_set)) != null) {
		$groups[$count]["id"] = $row["id"];
		$groups[$count]["name"] = $row["name"];
		$groups[$count]["mask"] = $row["mask"];
		$count++;
	}
	return $groups;
}

function printChapter($committee){

	echo "<table width=\"99%\" border=\"0\" cellspacing=\"10\">\n";

	foreach($committee as $name => $c){
		
		$alt = $name;
		$names = explode(" ", $name);
		$fname = $names[0];
		
		$lname = "";
		for($i = 1; $i <= 3; $i++){
			$lname .= isset($names[$i]);
		}
		
		if(array_key_exists('chapter', $c)){
			$chapter = $c['chapter'];
			switch($chapter){
				case 'ACT':
					$chapter = 'Australian Capital Territory';
					$page = 'ACT/';
					break;
				case 'NSW':
					$chapter = 'New South Wales';
					$page = 'NSW/';
					break;
				case 'QLD':
					$chapter = 'Queensland';
					$page = 'Queensland/';
					break;
				case 'SA':
					$chapter = 'South Australia';
					$page = 'SA/';
					break;
				case 'VIC':
					$chapter = 'Victoria';
					$page = 'Victoria/';
					break;
				case 'WA':
					$chapter = 'Western Australia';
					$page = 'WA/';
					break;
				case 'TAS':
					$chapter = 'Tasmania';
					$page = 'Tasmania/';
					break;
				case 'NZNorthern':
					$chapter = 'NZ Northern Region';
					$page = 'NZNorthern/';
					break;
				case 'Canterbury':
					$chapter = 'Canterbury';
					$page = 'Canterbury/';
					break;
				case 'Wellington':
					$chapter = 'Wellington';
					$page = 'Wellington/';
					break;
				case 'VCNZ':
					$chapter = 'Virtual Community (New Zealand)';
					$page = 'VirtualCommunity1.php';
					break;
				case 'VCAUS':
					$chapter = 'Virtual Community (Australia)';
					$page = 'VirtualCommunity2.php';
					break;
			}
		} else {
			$chapter = NULL;
		}

		if(array_key_exists('title', $c)){
			$title = $c['title'];
		} else {
			$title = 'Committee Member';
		}
			
		if(array_key_exists('email', $c)){
			$at = strpos($c['email'], "@");
			$prefix = substr($c['email'], 0, $at);
			$domain = substr($c['email'], ($at + 1));
		} else {
			$prefix = 'admin';
			$domain = 'ourdomain.com';
		}
		
		$img = strtolower(substr($fname, 0, 4));
		$img .= ucfirst(strtolower(substr($lname, 0, 4)));
		
		if(file_exists('./img/'.$img.'.jpg')){
			$img = './img/'.$img.'.jpg';
		} elseif(file_exists('./img/'.$img.'.gif')){
			$img = './img/'.$img.'.gif';
		} else {
			$img = './img/noimage.jpg';
			$alt = 'No image available';
		}

		$size = @getimagesize($img);
		$width = $size[0];
		$height = $size[1];
		
		if(array_key_exists('phone', $c)){
			$phone = $c['phone'];
		} else {
			$phone = NULL;
		}
		
		if(array_key_exists('fax', $c)){
			$fax = $c['phone'];
		} else {
			$fax = NULL;
		}
		
		if(array_key_exists('mobile', $c)){
			$mobile = $c['mobile'];
		} else {
			$mobile = NULL;
		}
		
		if(array_key_exists('cred', $c)){
			$cred = $c['cred'];
		} else {
			$cred = NULL;
		}
		
		if(array_key_exists('blurb', $c)){
			$blurb = $c['blurb'];
		} else {
			$blurb = NULL;
		}
		
		echo "<tr valign=\"top\">\n<td width=\"90\">\n";
		echo '<img src="'.$img.'" width="'.$width.'" height="'.$height.'" alt="'.$alt.'" />';
		echo "\n</td>\n<td><strong>";
		if($chapter){
			echo $chapter."</strong><br />\n";
			echo $title.": ";
		} else {
			echo $title."</strong><br />\n";
		}
		echo $name." ".$cred."<br />\n";
		if($phone){
			echo 'Phone: '.$phone.'<br />';
			echo "\n";
		}
		if($mobile){
			echo 'Mobile: '.$mobile.'<br />';
			echo "\n";
		}
		if($fax){
			echo 'Fax: '.$fax.'<br />';
			echo "\n";
		}
		if($blurb){
			echo $blurb.'<br />';
			echo "\n";
		}		
		echo "<script language=\"javascript\" type=\"text/javascript\">\n";
		echo "<!--\n";
		echo "var contact = 'Email {$fname}';\n";
		echo "var prefix = '{$prefix}';\n";
		echo "var domain = '{$domain}';\n";
		echo "document.write('<a href=' + 'mail' + 'to:' + prefix + '@' + domain + '>' + contact + '</a>');\n";
		echo "//-->\n</script>\n";
		if($chapter){
			echo "<br /><a href=\"./$page\">More information on ".$chapter."</a>\n";
		}
		echo "</td>\n</tr>\n\n";
	}

	echo "</table>";
}

?>

can anyone assist? Would be v.grateful...

This piece is wrong:

for($i = 1; $i <= 3; $i++){
			$lname .= isset($names[$i]);
		}

What you're actually saying is: Add the return-value of the function "isset" to the string "$lname". So it's trying to add true or false to your string. What you probably meant was:

for($i = 1; $i <= 3; $i++){
     if (isset($names[$i])) {
         $lname .= isset($names[$i]);
     }
}

Which means: If names has a value, add it to $lname.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.