Forum Moderators: coopster
on the admin page, they can add a title, taster, full story and an image. the image name is stored in a sql database as text, and i want to use the "img src" code to pull the file name from the database and view the picture. any ideas?
// generate and execute query
$id= $_GET['id'];
$query = "SELECT title, taster, full, pic, timestamp FROM news WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// get resultset as object
$row = mysql_fetch_object($result);
// print details
if ($row)
{
?>
<p>
<b><? echo $row->title;?></b>
<p>
<font size="-1"><? echo nl2br($row->taster);?></font>
<br />
<font size="-1"><? echo nl2br($row->full);?></font>
<br />
<img src="<? echo ($pic);?>">
<br />
<font size="-2">This press release was published on <? echo formatDate($row->timestamp);?>.</font>
<?
}
else
{
?>
<p> <font size="-1">That press release could not be located in our database.</font>
<?
}
// close database connection
mysql_close($connection);
?>
<p align="center"><a href="list.php">Back</a>
</body>
</html>
the database columns is called pic.
in this discussion [webmasterworld.com] someone mentions the <br /> tags can cause probalems when used in pure html docs
Go to the red x and look at the properties. How you do that depends on your browser; but in most cases, right click and select properties. Have a look at the path the browser is looking for the pic in, and compare that with the path the pic really is in.
You can't post a zip of your files, and it is not advisable to post the complete relevant pages. You can post short samples or snippets, so cut down your code to the bare minimum to show the problem, and make sure that you have removed any specific urls before posting it.
Shawn
when i use the code:
// print details
if ($row)
{
?>
<p>
<b><? echo $row->title;?></b>
<p>
<font size="-1"><? echo nl2br($row->taster);?></font>
<br />
<font size="-1"><? echo nl2br($row->full);?></font>
<br />
<img src=images/"<? echo ($pic);?>">
<br />
<font size="-2">This press release was published on <? echo formatDate($row->timestamp);?>.</font>
its gives me the path [blah...]
for whatever reason it won't replace the "" with the filename.