Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    87
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Question What's wrong with this code?

    Why is the code below not echoing the photo? What could be wrong with the line in dark orange?
    Code:
    <?php
    
    
    
    // Include database connection settings
    include('config.inc');
    
    //first select the post based on $_GET['Index']
    
    $Index = $_GET['Index'];
    $sql = "SELECT * FROM `entries` WHERE `Index` ='$Index' ";
    
    
    $result = mysql_query($sql) or die(mysql_error());
    
    
    //display story data
    while($row = mysql_fetch_assoc($result))
    {
    header('Content-type: text/html; charset=utf-8');
    echo '<img src="/scripts/timthumb.php?src=' . $row['Photo_link'] . '&w=425&zc=1" alt="" /><br><br>';
    echo ' ' . nl2br($row['Post']) . '<br>';
    
    
    }
    
    
    
    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    There's nothing wrong syntactically with it.
    Although you make many assumptions. $_GET['Index'] isn't checked for being valid (and is also open to SQL injection), $row['Photo_link'] is assumed as being valid as well. The header should be moved out of the loop.
    Check your source output HTML. If it shows a valid ?src=xxx in it, than the problem is your path.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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