Page 1 of 1

How define a variable to display an Image

Posted: Mon May 12, 2003 10:01 pm
by guycrossley
Hello,

I want to display an image, who's location is stored in a string. For Example:

$temp = "Images/UserIcons/Brettsface.png";

But, when i try

<img src= $temp width="100" height="100">

I dont get anything... What have i done wrong?

--Guy

(PS- However, this works <img src= "Images/UserIcons/Brettsface.png" width="100" height="100"> )

Posted: Mon May 12, 2003 10:34 pm
by AVATAr

Code: Select all

<?php
$temp = "Images/UserIcons/Brettsface.png"; 
echo '<img src= "'.$temp.'" width="100" height="100">';  //check de simple quotes and the double quotes around $temp
?>

Posted: Tue May 13, 2003 1:17 am
by Czar
you can also leave the php block and do it like;

Code: Select all

<?php 
$temp = "Images/UserIcons/Brettsface.png"; 
?>

<img src=<?php echo $temp; ?> width="100" height="100">

Posted: Tue May 13, 2003 9:04 am
by lc
So many options... I usually do it like this:

Code: Select all

<?php
print "<img src="$temp" width="100" height="100">"; 
?>

Posted: Tue May 13, 2003 8:14 pm
by guycrossley
ah, thanks guys. The following code worked:

Code: Select all

<?php $temp = "Images/UserIcons/Brettsface.png";
   echo '<img src="'.$temp.'">'; 
?>
But this didn't, why?

Code: Select all

<?php $temp = $row_rsUsers&#1111;'USER_ICON']; 
    echo '<img src="'.$temp.'">'; 
?>
Is this a database issue, or is there a datatype mismatch or something?

Posted: Tue May 13, 2003 8:28 pm
by guycrossley
Ignore the last post,

$row_rsUsers['USER_ICON']

was returning an array because i didnt define the recordset correctly.

Thx for all your help guys! :D