Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2003

    Unanswered: Trying to display an image via php

    I am trying to display some data that i have stored in my mysql database,

    I seem to have worked the code out for the text that i want displayed but when i enter the info for the photo that is stored in my mysql i just get the web link displayed instead of the actual image.

    My Mysql database structure is as follows:

    create table Players
    ( PlayerID integer not null primary key auto_increment
    , Forename varchar(50) 
    , Surname varchar(50) not null
    , DOB date
    , RegNo tinyint
    , Photo varchar(255)
    , Nickname varchar(50)
    , Comments varchar(255)
    , Position varchar(50)
    , GamesPlayed tinyint
    , GoalsScored tinyint
    My php code is as follows:

    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM players";
    echo "<b><center>Database Output</center></b><br><br>";
    while ($i < $num) {
    echo "<b>$Forename$Surname</b><br>Date Of Birth: $DOB<br>Nickname: $Nickname<br>Photo: $Photo<br><br><hr><br>";
    the image is stored in the table under the field called Photo, it is stored as a url to the image as follows:

    but is displayed as follows

    Date Of Birth: 1971-04-08
    Nickname: Gaffer

    Please Help

    Thanks in advance

  2. #2
    Join Date
    Apr 2006
    Denver, Co. USA
    To get the actual image to be output to the browser, you need to put the url into a HTML <img... tag. Here is a link to a fairly good HTML reference -

  3. #3
    Join Date
    Mar 2003
    sorry and excuse my ignorance, do you mean when i store it in my MYSQL database i should store it as :

    <IMG SRC="">

  4. #4
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    Store thge data as required, but when its used by the client program make any chnages required for use for that client program

    so store your image as a path to the image - incidentally it woudl be better to use a UNC path eg //server/path/to/file.ext

    if the client application is HTML (and if you are using PHP thats almost a given) then wrap the image with <img> tags. bear in mind you could also do some error checking in PHP to see if the file exists and test if its a graphics / picture.

    if the target is a another applciation then you woudl want jsut the url to the file. There is nothign stopping you if you want to stroe the path to the image with img tags - its just not clever if your applciasiton ever need to use the path in a non HTMl environment.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2003
    i am using html, but this lot here is saved as a php file,

    i understand what you mean about the UNC path eg //server/path/to/file.ext and will bear that in mind.

    however i am really lost as to the img thing i really dont understand how i fit that into my php code to get the picture to display...

    really sorry for appearing dumb

  6. #6
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    $out .= "<img src=\".$prow['Std_URL'])."\" width=\"".$iSize['0']."\" height=\"".$iSize['1']."\" border=\"0\" alt=\"Select this for a more detailed image\">";
    this snippet may help
    $out is the variable holding the information to be displayed as html
    $pRow contains the resultset from the MySQL query
    $iSize contains the image size calculated from the GDI functions
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts