Page 1 of 1

Rerieve Image path from database ---- problem please help

Posted: Thu Feb 05, 2009 4:13 am
by tinoda
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:

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);
?>
 
the code i use to try to retrieve and see my images is as follows:

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);
?>
 
The first code successfully writes everything to the database but the second code only outputs the ID number and red boxes without my images.

Re: Rerieve Image path from database ---- problem please help

Posted: Thu Feb 05, 2009 4:48 am
by mickeyunderscore
Have you checked the image path actually being used? e.g. not the one in the database? Try right-clicking the broken image and select properties, this should give you the full path to the image that is being used.

Re: Rerieve Image path from database ---- problem please help

Posted: Thu Feb 05, 2009 4:59 am
by tinoda
mickeyunderscore wrote:Have you checked the image path actually being used? e.g. not the one in the database? Try right-clicking the broken image and select properties, this should give you the full path to the image that is being used.
..actually thats what is making my head go round because the full path is exactly the same as the path i stored in the database.