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
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Thu Sep 04, 2008 9:19 pm
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
Post
by paperplate » Thu Sep 04, 2008 9:25 pm
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!!!
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Thu Sep 04, 2008 9:32 pm
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
Post
by paperplate » Fri Sep 05, 2008 10:24 pm
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.
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Thu Sep 11, 2008 1:46 pm
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