Rerieve Image path from database ---- problem please help
Posted: Thu Feb 05, 2009 4:13 am
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:
the code i use to try to retrieve and see my images is as follows:
The first code successfully writes everything to the database but the second code only outputs the ID number and red boxes without my images.
the first one to save the image path to database:
Code: Select all
<?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);
?>
Code: Select all
<?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);
?>