SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    931
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image not loading from image.php

    Hi all,

    My site has problem loading pictures fom the database recently..its working fine all along

    I have created a testing script to load the picture:

    http://absolutethree.com/testing.php

    My page shows a big 'RED X' error image loading..

    My testing.php includes the following codes:
    PHP Code:
    $no=1;
    $find_im=mysql_query("SELECT id FROM avatar WHERE Kid='$no'",$link ) or die(mysql_error());

    $im=mysql_fetch_array($find_im);
        
    if (
    $im[0]) echo"<img id='avatar' src='image.php?Kid=$no'>"//output image if match with db
    else echo'No image found<p>'//print error if no image found in db 
    My image.php:
    PHP Code:
    if ($_REQUEST['Kid']!=NULL) {
            
    $realm_banner=mysql_query("SELECT * FROM avatar WHERE Kid = '".$_REQUEST['Kid']."' " ,$link ) or die(mysql_error());         
            
    $pic=mysql_fetch_array($realm_banner);  
            
    $data $pic['Content']; 
               
    $type $pic['Type']; 
            
    Header("Content-type: image/$type");                  
            echo 
    "$data";         
            } 
    The critical problem here is that my code does not show an error if it fails to load the image..instead it gives a 'red X'
    Therefore, i think that the script can find the image and its just that it cannot load it from the db
    Can anyone give me some advices?
    Thank you.

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Run the image PHP file directly from your browser frist to make sure there are no PHP errors (remove the header() call to output text just inc ase there are errors)

    Then to debug just do simple print $variable to check each variable to make sure it is correct.

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not a 100% on php but shoudn't

    SELECT * FROM avatar WHERE Kid = '".$_REQUEST['Kid'].

    be

    SELECT * FROM avatar WHERE Kid = '".$_REQUEST['$no'].

    or possibly

    SELECT * FROM avatar WHERE Kid = '".$_REQUEST['no'].

  4. #4
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://absolutethree.com/image.php?Kid=1 shows:
    Warning: Cannot modify header information - headers already sent by (output started at /home/absolute/public_html/connect.php:26) in /home/absolute/public_html/image.php on line 27
    What's line 26 of connect.php ?

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably a blank line or an echo. Good find mark!

  6. #6
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    931
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think i know where's the problem...

    It lies in my connect.php, it will work if i do not close the file:
    PHP Code:
    <?
    //connect.php
    $mysqluser="root";
    //...
    //..
    If i close it with ?> then it will not be shown

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by KCgame
    I think i know where's the problem...

    It lies in my connect.php, it will work if i do not close the file:
    PHP Code:
    <?
    //connect.php
    $mysqluser="root";
    //...
    //..
    If i close it with ?> then it will not be shown
    No you just need to make sure there are no extra whitespace after your closing tag.

  8. #8
    Internet Business Optimizer KCgame's Avatar
    Join Date
    Mar 2005
    Location
    Singapore
    Posts
    931
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xmitchx
    No you just need to make sure there are no extra whitespace after your closing tag.
    Thanks for the help
    Learn something valuable today^^


Bookmarks

Posting Permissions

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