image link to display from row

Discussion in 'PHP' started by xbat, Apr 10, 2011.

  1. #1
    hello... if someone could please give me a few pointers..

    what i have is...

    $sql = mysql_query("select * from products where link like '%$term%'");
    while ($row = mysql_fetch_array($sql)){
    echo '<br/> Upc: '.$row['jan'];
    echo '<br/> '.$row['image_link'];
    }

    image_link is a link to a image http://yaoo.com/image.jpg


    Question -

    How would I get a image to display on the web page?

    I have tried things like - echo "<td><img src='" . $row['image_link'] . "' /></td>";

    $i++;


    I keep on getting snyatx errors.

    thanks:cool:
     
    xbat, Apr 10, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Hi,

    By looking at the img line it seems correct, could you please post original code snippet itself along with the exact error message? That would help us identify problem correctly.
     
    mastermunj, Apr 10, 2011 IP
  3. xbat

    xbat Well-Known Member

    Messages:
    326
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Thanks.. Yea I am not sure if there is a better way to build it or not... but here it is.. I just can't get the image to display...


    ERROR: Parse error: syntax error, unexpected '"', expecting ',' or ';' in /home/worldupc/public_html/search.php on line 19

    Code:

    $sql = mysql_query("select * from products where link like '%$term%'");
    while ($row = mysql_fetch_array($sql)){
    echo '<br/> Upc: '.$row['jack'];
    echo '<br/> <img src='"'.$row['image_link']. "' />;
    }


    This is the line - echo '<br/> <img src='"'.$row['image_link']. "' />; I just can't get the image to show... because in image_link is http://jackone.com/boo.jpg ... I can however get the link to load fine just no image to show due to the <img link that I built..
     
    xbat, Apr 10, 2011 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Change following

    
    echo '<br/> <img src='"'.$row['image_link']. "' />;
    
    PHP:
    into

    
    echo '<br/> <img src="' . $row['image_link'] . '" />';
    
    PHP:
     
    mastermunj, Apr 10, 2011 IP
  5. xbat

    xbat Well-Known Member

    Messages:
    326
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    105
    #5
    ah! you are awesome! THANK YOU!! its always something stupid.. You want any money ? I'll send you $5.00 or something that sound ok?
     
    xbat, Apr 10, 2011 IP
  6. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #6
    Hi, Glad I could help.

    No, I did not do this one for money :)

    Thanks for kind gesture though.
     
    mastermunj, Apr 10, 2011 IP