将MYSQL字符串插入图像源以进行显示

I know I am doing something very simple that's wrong...I just can't figure it out. Any suggestions?

<img src='photos/<?php echo $row['filename'];?>/'>;

Im looking for to be inserted to look like <img src="photos/$row['filename']"> < but that is not the proper format.

When outputing your string inside a php file use following code

echo '<img src="photos/' . $row['filename'] . '">';

For better readability you could use printf:

printf('<img src="photos/%s">', $row['filename']);

Remove the trailing slash from your declaration.

<img src='photos/<?php echo $row['filename'];?>'>

Most servers won't respond in the way you expect when you add a trailing slash (/) to the filename of a resource. Picky, but technically wrong, because a file is not a directory (referencing a directory in certain environments requires the trailing slash).

When evaluated, your expression will come out to something akin to

<img src='photos/img001.jpg/'>

when in reality, that resource is actually at

<img src='photos/img001.jpg'>

I see a trailing slash at the end of the img tag. It may cause this problem.

The easies way that can make you avoid "" and '' problems is to make html string on echo :

echo "<img src='photos/" . $row['filename'] . "' />";