Page 1 of 1

Displaying the Image from MySQL, help please...

Posted: Sun Aug 26, 2007 12:04 pm
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>

Posted: Sun Aug 26, 2007 12:19 pm
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?