Ok, what i'm trying to do here is in the code i'm telling it to take 4 fields from the db. Put them into an array. Then i tell it that if one of those vars out of the array == default.gif unset that var.. Like unset $var[2] if it is set. or if var[4] is set unset it. Then i tell it with a foreach loop to display everything in $pics that is set. Again i hope that my if statement will unset everythin in $pics that == default.gif. I get a parse error on my ifstatement and it doens't seem to work. Any suggestions?
$sql = "SELECT * FROM users WHERE user='$name'";
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result) or die(mysql_error());
$mainpic = $row['mainpic'];
$pic1 = $row['pic1'];
$pic2 = $row['pic2'];
$pic3 = $row['pic3'];
$pic4 = $row['pic4'];
$pics = array($pic1,$pic2,$pic3,$pic4);
if ($pics[] == "default.gif") { unset($pics[]) }
foreach($pics as $picname)
{
$table .= "
<td align=center><a href=http://c.com/viewimage.php?image=$picname&name=$name> <span style='text-decoration: none'><img
src=http://.com/pics/$picname height=80 width=80></a></span></td>
";
}
The error i get with this code is
Fatal error: Cannot use [] for reading in / on line 46
if ($pics[] == "default.gif") { unset($pics[]) }
that is line 46
that is my problem. As if you notice i'm trying to unset the var