php - Display an image that is stored in a directory in browser -
this seems such simple thing reason, can't work.
i have database vehicle data stored in it. (used cars (i'm developing car dealership website)).
i display results database without images.
the images each record aren't stored in database, instead they're dumped on server in directory , images referenced in database.
if echo image name out works fine, , if echo actual image out, path correct if @ image info. in info states image of text. don't know how change this.
please find of code below.
<?php $dbname = "f:/domains/autodeal/autodeal.co.za/wwwroot/newsite/db/savvyautoweb.mdb"; // throws error if database cannot found if (!file_exists($dbname)) { die("could not find database file."); } // connects database // assumes there no username or password $conn = odbc_connect("driver={microsoft access driver (*.mdb)};dbq=$dbname", '', ''); //this selecting individual records $selected_id = intval($_get['id']); //this query $sql = "select id, make, model, year, price, specialprice, branch, stockno, mainpic vehicle id = $selected_id"; // runs query above in table $rs = odbc_exec($conn, $sql); $id = odbc_result($rs, id); $make = odbc_result($rs, make); $model = odbc_result($rs, model); $mainpic = odbc_result($rs, mainpic); //this failsafe when there no images specific record $no_image = "<a href='db/nopic.gif' data-lightbox='nopic' title='no image available'><img src='db/nopic.gif' /></a>"; //this displays name of image referenced in database $main_pic = "<img src='db/vehicleimages/'" .$mainpic. "/>"; //this supposed display actual echo $main_pic . "<br />"; echo $no_image; odbc_free_result($rs); odbc_close($conn); // message displayed if query has error in if (!$rs) { exit("there error in sql!"); } ?>
any in regard appreciated.
thank you. :)
you should use quotations around attributes of html objects (it looks might breaking things via method):
yours:
<a href=db/nopic.gif data-lightbox=nopic title=no image available><img src=db/nopic.gif /></a>
correct:
<a href='db/nopic.gif' data-lightbox='nopic' title='no image available'><img src='db/nopic.gif' /></a>
whether or not fixes problem determined come :p
Comments
Post a Comment