I am trying to display all images on a page using this query.. however it is giving me syntax problem.. Parse error: syntax error, unexpected '>'
<?php
$result = mysql_query("SELECT * FROM my_image, $connection);
while($row = mysql_fetch_array($result))
{
echo "<div><img src=\"uploadedimages/".$row['name']."\" /></div>"
}
?>
anyone knows whats wrong?
You're missing a closing double quote:
mysql_query("SELECT * FROM my_image", $connection);
^
You're missing a terminating semi-colon:
echo "<div><img src=\"uploadedimages/".$row['name']."\" /></div>";
^
May I recommend:
echo '<div><img src="uploadedimages"' . $row['name'] . '" /></div>';
Also, stop using mysql_
functions. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.