Displaying the Image from MySQL, help please...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
desktopdevil2000
Forum Newbie
Posts: 2
Joined: Sat Aug 25, 2007 4:31 pm

Displaying the Image from MySQL, help please...

Post by desktopdevil2000 »

I was able to successfully upload the image to mysql, how can i display it though? let me know what's wrong with my query...

Code: Select all

<?php
mysql_connect("mysql", "username", "password") or die(mysql_error());
  mysql_select_db("cleverwebdesigns");</p> <p>$result = mysql_query("SELECT id from upload");
while ($row = mysql_fetch_array($result)) {
  $ids[]=$row['id'];
}
?>
<html>
<head>
<title>Image Loader</title>
</head></p><p><body>
select image:<br>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%">id</td>
<td width="90%">Image</td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="?id=<?= $id; ?>"><?= $id; ?></a></td>
</tr>
</table></td>
<td><img src="image.php?id=<?= $_GET['id']; ?>"></td>
</tr>
</table> 
</body>
</html>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Don't use the <?= ?> or <? ?> syntax. Always use <?php echo .. ?>. short_open_tags isn't going to be around forever ;)

We'll need to see image.php to know why it's not working. Have you tried going to image.php?id=something directly in your browser?
Post Reply