I can't display a default picture; keep getting error.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

I can't display a default picture; keep getting error.

Post by cap2cap10 »

:banghead: 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!!!
paperplate
Forum Newbie
Posts: 16
Joined: Thu Sep 04, 2008 12:15 pm

Re: I can't display a default picture; keep getting error.

Post 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::banghead: 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!!!
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: I can't display a default picture; keep getting error.

Post 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
paperplate
Forum Newbie
Posts: 16
Joined: Thu Sep 04, 2008 12:15 pm

Re: I can't display a default picture; keep getting error.

Post 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.
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: I can't display a default picture; keep getting error.

Post 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. :banghead:

Thanks again, Batoe
Post Reply