Jump to content

Help with img tab <img src="images/John-Coltrane.jpg">


johnseito

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.