worldcomingtoanend Posted February 5, 2009 Share Posted February 5, 2009 I am trying to output my image path that i have saved to the database. i need the output to be my literal images. The output I am getting is table of ID numbers which is fine but instead of images next to the ID numbers I get broken image triangles with exclamation marks. I have tried to double check my image path, absolute paths, etc but nothing is working. OK now let me give u the 2 codes, a). The one I used to save the image path b) the one i used to try retrieve the image. the first one to save the image path to database: <?php $db = odbc_connect("asas","asass","asasa"); $sql = "INSERT INTO foto (id, url) VALUES (" . " 101, 'gg/Fotos/bild1.jpg')"; $res = odbc_exec($db, $sql); if (!$res) { print("SQL statement failed with error:\n"); print(odbc_error($db).": ".odbc_errormsg($db)."\n"); } else { print("One data row inserted.\n"); } $sql = "INSERT INTO foto (id, url) VALUES (" . " 102, 'gg/Fotos/bild2.jpg')"; $res = odbc_exec($db, $sql); print("One data row inserted.\n"); odbc_close($db); ?> the code i use to try to retrieve and see my images is as follows: <?php $db = odbc_connect("asas","asass","asasa"); $sql = "SELECT id, url FROM foto"; $res = odbc_exec($db, $sql); while ($row = odbc_fetch_array($res)) { print($row['id'].",<img src='".$row['url']."'>,".$row['time']."\n"); } odbc_free_result($res); odbc_close($db); ?> The first code successfully writes everything to the database but the second code only outputs the ID number and red boxes without my images. Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/ Share on other sites More sharing options...
waynew Posted February 5, 2009 Share Posted February 5, 2009 Hi, Could you post the resulting HTML of your script so that we can see what the end result is? Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755125 Share on other sites More sharing options...
waynew Posted February 5, 2009 Share Posted February 5, 2009 Try echo $row['id'].'<img src="'.$row['url'].'" />'.$row['time']."\n"; Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755127 Share on other sites More sharing options...
worldcomingtoanend Posted February 5, 2009 Author Share Posted February 5, 2009 Try echo $row['id'].'<img src="'.$row['url'].'" />'.$row['time']."\n"; the output i get is as below 101101 >102102 >101101 <102102 >101101 <102102 <101101 <102102 <101101 <102102 the flex brackets that i have put are actually triangles that r out put. Strangely the actual HTML output i get after clicking on view source is as below. It seems strange: <span class="content"> 101,<img src='gg/Fotos/bild1.jpg'>, 102,<img src='gg/Fotos/bild2.jpg'>, 101,<img src='gg/Fotos/bild1.jpg'>, 102,<img src='gg/Fotos/bild2.jpg'>, 101,<img src='gg/Fotos/bild1.jpg'>, 102,<img src='gg/Fotos/bild2.jpg'>, 101,<img src='gg/Fotos/bild1.jpg'>, 102,<img src='gg/Fotos/bild2.jpg'>, 101,<img src='gg/Fotos/bild1.jpg'>, 102,<img src='gg/Fotos/bild2.jpg'>, 101,<img src='www.sasass.com/picos/take/one.jpg'>, 102,<img src='www.sasass.com/picos/take/two.jpg'>, 101,<img src='www.sasass.com/picos/take/one.jpg'>, 102,<img src='www.sasass.com/picos/take/two.jpg'>, 101,<img src=''g/Fotos/bild2.jpg'>, 102,<img src='g/Fotos/bild2.jpg'>, 101,<img src=''g/Fotos/bild2.jpg'>, 102,<img src='g/Fotos/bild2.jpg'>, 101,<img src=''g/Fotos/bild2.jpg'>, 102,<img src='g/Fotos/bild2.jpg'>, 101,<img src=''g/Fotos/bild2.jpg'>, 102,<img src='g/Fotos/bild2.jpg'>, 101,<img src=''g/Fotos/bild2.jpg'>, 102,<img src='g/Fotos/bild2.jpg'>, Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755134 Share on other sites More sharing options...
ashishag67 Posted February 5, 2009 Share Posted February 5, 2009 <?php $db = odbc_connect("asas","asass","asasa"); $sql = "SELECT id, url FROM foto"; $res = odbc_exec($db, $sql); while ($row = odbc_fetch_array($res)) { ?> <?php echo $row['id'];?>, <img src="<?php echo $row['url'];?>">, <?php echo $row['time'] . "\n";?> <?php } odbc_free_result($res); odbc_close($db); ?> Please try this code, if it works do let me know. Cheers Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755186 Share on other sites More sharing options...
worldcomingtoanend Posted February 5, 2009 Author Share Posted February 5, 2009 i tried the code above and I get the same output as before but this time if I hover on the triangles it displays my image path and if I click on the triangles it displays the code below: <?php echo $row['url'];?> Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755264 Share on other sites More sharing options...
ashishag67 Posted February 5, 2009 Share Posted February 5, 2009 <?php $db = odbc_connect("asas","asass","asasa"); $sql = "SELECT id, url FROM foto"; $res = odbc_exec($db, $sql); while ($row = odbc_fetch_assoc($res)) { ?> <img src="<?php echo $row['url'];?>"> <?php } odbc_free_result($res); odbc_close($db); ?> Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755270 Share on other sites More sharing options...
worldcomingtoanend Posted February 5, 2009 Author Share Posted February 5, 2009 the code above is even worse this time it displays nothing. Link to comment https://forums.phpfreaks.com/topic/143905-rerieve-image-path-from-database-problem-pliz-help-am-now-depressed/#findComment-755297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.