johnseito Posted February 21, 2008 Share Posted February 21, 2008 Hello all, I was wondering if anyone can help me with putting this code in php. images is the directory, and John-Coltrane.jpg is the pic in the directory. So how can I do this if I am trying to get the img out of the directory onto the browser with php. would it be like this? Echo "<img src=images/$info['photo']/><br>"; images is the directory and $info['photo'] is the name of the img in the sql database, I did this and it doesn't work, any advise? thanks Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/ Share on other sites More sharing options...
AndyB Posted February 21, 2008 Share Posted February 21, 2008 Take a look at the html generated by your php. That'll likely show you what the problem is. We might need to see a bit more of your php code if you're stuck. Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472409 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2008 Share Posted February 21, 2008 The single quotes around the array index name contained in a double-quoted string cause a fatal parse error - Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in ...\your_file.php on line 2 Use this - echo "<img src=images/{$info['photo']}/><br>"; Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472412 Share on other sites More sharing options...
cyrixware Posted February 21, 2008 Share Posted February 21, 2008 Take a look at the html generated by your php. That'll likely show you what the problem is. We might need to see a bit more of your php code if you're stuck. Hello all, I was wondering if anyone can help me with putting this code in php. images is the directory, and John-Coltrane.jpg is the pic in the directory. So how can I do this if I am trying to get the img out of the directory onto the browser with php. would it be like this? Echo "<img src=images/$info['photo']/><br>"; images is the directory and $info['photo'] is the name of the img in the sql database, I did this and it doesn't work, any advise? thanks You cannot use that inside of the echo.... If you want to get the image try this one using html.. <?php codes........ ?> <img src="../John-Coltrane.jpg"> or <img src="images/John-Coltrane.jpg"> <?php codes.......... ?> Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472413 Share on other sites More sharing options...
johnseito Posted February 21, 2008 Author Share Posted February 21, 2008 Thanks all, Echo "<img src=images".$info[photo]."> <br>"; this seems to work but I am trying to size the pix, like adding width and height for example like Echo "<img src=images".$info[photo]. width=200 height=200"> <br>"; and this doesn't work, any idea? Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472433 Share on other sites More sharing options...
bpops Posted February 21, 2008 Share Posted February 21, 2008 Error in your code Echo "<img src=images".$info[photo]. width=200 height=200"> <br>"; change to Echo "<img src=images".$info[photo]." width=200 height=200> <br>"; Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472437 Share on other sites More sharing options...
AndyB Posted February 21, 2008 Share Posted February 21, 2008 Automatically get the right size for any image... <?php $img = "images/". $info['photo']; $size = getimagesize($img); echo "<img src='". $img. "' ". $size[3]. "'><br>"; ?> Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472438 Share on other sites More sharing options...
johnseito Posted February 21, 2008 Author Share Posted February 21, 2008 thanks - Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472443 Share on other sites More sharing options...
johnseito Posted February 21, 2008 Author Share Posted February 21, 2008 do you know why that when I refresh the browser the last upload pic doubles? know how i can fix that? Link to comment https://forums.phpfreaks.com/topic/92218-help-with-img-tab/#findComment-472445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.