Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to put an img src tag around a variable?

Status
Not open for further replies.

tippytarka

Programmer
Jul 19, 2004
115
GB
i'm trying to create a img src tag around a variable.. for example...

$target_path_2 is a path to an image file in a directory ... photos/test.jpg

this gets entered into my database, when recalling the path from my database i'm trying to put an image tag around it and put into a new variable like so...

Code:
$path= '<img src"'.$target_path_2.'">';

after trying various ways i'm stumped on how to do it.. can anyone help?

cheers
 
How about:
Code:
$tag="<img src='" . $target_path_2 . "'>";



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
the result came out like this...

<img src"test/14-1.jpg">

missing the = and should be <img src="test/14-1.jpg">
 
You must be doing something wrong.

if I do this:

Code:
$target_path_2="\somedir\subdir\filename.txt"; [green]\\just for testing purposes.[/green]

$tag=$tag="<img src='" . $target_path_2 . "'>";

echo $tag;
[green]//The resulting html code looks like:
[/green]

<img src='\somedir\subdir\filename.ext'>

Maybe something inside your $target_path_2 is not correct.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
thanks vacunita, i must be going blind... i gotta step away from the computer for a while!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top