Page 1 of 1

Output Images from Database - Problem - help

Posted: Mon Feb 02, 2009 2:47 am
by tinoda
I saved my image path to a database and tried to retrieve the actual images using the code below.
<?php
$db = odbc_connect("asaa","asaa_user","asas");
$sql = "SELECT id, url, time FROM fotogalerie";
$res = odbc_exec($db, $sql);
while ($row = odbc_fetch_array($res)) {
print($row['id'].",".$row['url'].",".$row['time']."\n");
}
odbc_free_result($res);

odbc_close($db);
?>
Instead of getting the images that I need I get the output below:
101,/gg/en/pple/007_old/image1.jpg, 102,/gg/en/pple/007_old/image1.jpg,
101,/gg/en/pple/007_old/image2.jpg, 102,/gg/en/pple/007_old/image2.jpg,
101,/gg/en/pple/007_old/image3.jpg, 102,/gg/en/pple/007_old/image3.jpg,

where am I going wrong? Thank for your help.

Re: Output Images from Database - Problem - help

Posted: Mon Feb 02, 2009 2:59 am
by susrisha
This is where you have gone wrong i think.

Code: Select all

 
print($row['id'].",".$row['url'].",".$row['time']."\n");
 
What you are doing is just printing the url of the image as a string. It doesnot give any images.

try to put an image tag like this=>

Code: Select all

 
print($row['id']);
?>
<img src="<?php echo $row['url']; ?>" size=(your image size)/>
<?php 
echo $row['time']."\n";
 

Re: Output Images from Database - Problem - help

Posted: Mon Feb 02, 2009 3:16 am
by tinoda
thanks but now its giving me this output:

Code: Select all

101101 >102102 >101101 <102102 >101101 <102102 <101101 <102102 <101101 <102102
the flex brackets that i have put are actually triangles that r out put and if i place my mouse pointer on the triangles it displays a message with my image path and also says unresolved link. If i click the triangle it also outputs this code: <?php echo $row['url']; ?>

Re: Output Images from Database - Problem - help

Posted: Mon Feb 02, 2009 5:31 am
by susrisha
try this one
must be some problem with the url linking

Code: Select all

 
<IMG height="image height" src="<?php echo (your url from db); ?>" width="imagewidth">