ryanwood4 Posted September 25, 2009 Share Posted September 25, 2009 Hi, I'm using the code I wrote below - (I'm a novice, so it could be completely wrong) - to display images which are stored in a folder on a server. The url to the images are kept in a database: gallery2, table: g2_FileSystemEntity column: g_pathComponent But I can't seem to make it work. I want the code to display an image, and link to the larger image in the gallery. The gallery url for each image starts: http://www.f1times.co.uk/gallery2/gallery2Embedded.php?g2_itemId= and then after the equals each image has a unique id. This is under g_id column. This is what I want the image to link to when clicked. The images themselves are stored here: ttp://www.f1times.co.uk/gallery2/g2data_b0f3726a/albums/ (the image file name is stored in the database I mentioned above) Any help would be very helpful. <?php $con = mysql_connect("xxxx","xxxx","xxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("f1times_gallery2", $con); $result = mysql_query("SELECT * FROM g2_FileSystemEntity ORDER BY g_id DESC LIMIT 0,1"); while($row = mysql_fetch_array($result)) { $url = "http://www.f1times.co.uk/gallery2/gallery2Embedded.php?g2_itemId=" . $row['g_id']; $image = "http://www.f1times.co.uk/gallery2/g2data_b0f3726a/albums/" . $row['g_pathComponent']; echo "<a href='$url' target=_parent>"."img src="($row['$image'])."</a>"; } mysql_close($con); ?></tr></table> Quote Link to comment https://forums.phpfreaks.com/topic/175503-solved-displaying-images-stored-in-database/ Share on other sites More sharing options...
Bricktop Posted September 25, 2009 Share Posted September 25, 2009 Hi ryanwood4, In your echo statement: echo "<a href='$url' target=_parent>"."img src="($row['$image'])."</a>"; $row['$image'] does not exist and the whole line is not valid syntax anyway. Change your code to read: echo '<a href="'.$url.'" target="_parent"><img src="'.$image.'" /></a>'; Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/175503-solved-displaying-images-stored-in-database/#findComment-924763 Share on other sites More sharing options...
ryanwood4 Posted September 25, 2009 Author Share Posted September 25, 2009 Ahah, that solved the error. Thanks. Still one problem, them images aren't displaying, but they are linking correctly. The page - http://www.f1times.co.uk/gallery_mini.php Quote Link to comment https://forums.phpfreaks.com/topic/175503-solved-displaying-images-stored-in-database/#findComment-924777 Share on other sites More sharing options...
ryanwood4 Posted September 25, 2009 Author Share Posted September 25, 2009 Oh, I think it may be a permission thing. Thanks Bricktop! Quote Link to comment https://forums.phpfreaks.com/topic/175503-solved-displaying-images-stored-in-database/#findComment-924778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.