Page 1 of 1
I can't display a default picture; keep getting error.
Posted: Thu Sep 04, 2008 9:19 pm
by cap2cap10

hey, php technorati, I keep getting this error message:
Parse error: syntax error, unexpected T_ELSE in ............pic.php on line 23
when I use this code:
Code: Select all
<?php
include 'open_resume_db.php';
$userID=$_SESSION['login']['userID'];
$query = "SELECT image_type FROM js_resume WHERE userID = '$userID'";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
$image_type = $row['image_type'];
}
$imagelocation = 'uploads/'.$userID.'.'.$image_type;
$imagesize = getimagesize($imagelocation);
$width = .999 * $imagesize['0'];
$height = .999 * $imagesize['1'];
echo '<img src = "'.$imagelocation.'" height="'.$height.'" width="'.$width.'">';
else {
echo '<img src="images/nopic.jpg" width="100" height="130" border="0">';
}
include 'closedb.php';
?>
All I want to do is display a default picture when a user has not uploaded a picture file yet.
Can someone enlighten me!!!
Re: I can't display a default picture; keep getting error.
Posted: Thu Sep 04, 2008 9:25 pm
by paperplate
You want an IF, not a WHILE. It seems like you only need one record, so no need to loop. Therefore note a changed line 10 and the change in braces.
cap2cap10 wrote:
hey, php technorati, I keep getting this error message:
Parse error: syntax error, unexpected T_ELSE in ............pic.php on line 23
when I use this code:
Code: Select all
<?php
include 'open_resume_db.php';
$userID=$_SESSION['login']['userID'];
$query = "SELECT image_type FROM js_resume WHERE userID = '$userID'";
$result = mysql_query($query) or die(mysql_error());
if ($row = mysql_fetch_assoc($result))
{
$image_type = $row['image_type'];
$imagelocation = 'uploads/'.$userID.'.'.$image_type;
$imagesize = getimagesize($imagelocation);
$width = .999 * $imagesize['0'];
$height = .999 * $imagesize['1'];
echo '<img src = "'.$imagelocation.'" height="'.$height.'" width="'.$width.'">';
}
else
{
echo '<img src="images/nopic.jpg" width="100" height="130" border="0">';
}
include 'closedb.php';
?>
All I want to do is display a default picture when a user has not uploaded a picture file yet.
Can someone enlighten me!!!
Re: I can't display a default picture; keep getting error.
Posted: Thu Sep 04, 2008 9:32 pm
by cap2cap10
Thanks, Seems logical but now I am getting the following error:
Parse error: syntax error, unexpected T_DNUMBER in ..........pic.php on line 3
Can anyone fix this error?
Batoe
Re: I can't display a default picture; keep getting error.
Posted: Fri Sep 05, 2008 10:24 pm
by paperplate
cap2cap10 wrote:Thanks, Seems logical but now I am getting the following error:
Parse error: syntax error, unexpected T_DNUMBER in ..........pic.php on line 3
Can anyone fix this error?
Batoe
You'll have to post some code.
Re: I can't display a default picture; keep getting error.
Posted: Thu Sep 11, 2008 1:46 pm
by cap2cap10
Thanks I fixed it! I cut and pasted the numbers from the above code on to my php editor and did not notice there were to sets of line numbers.
Thanks again, Batoe