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 to the CF scene
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Easy help needed..

    I am querying my database to see if the record has an image. if it doesn't I want to show a white box. if it does have an image in the record, I want to show the image as shown below

    <? $media_url = $db->get_sql_field("SELECT media_url FROM " . DB_PREFIX . "item_media WHERE item_id=" . $item_details['item_id'] . " AND

    media_type=1 AND upload_in_progress=0 ORDER BY media_id ASC", 'media_url'); ?>

    <? if (empty($media_url))

    {
    echo '<img src="/images/blank.png" height="100" width="100">';
    }

    else

    {
    echo '<img src="<?=SITE_PATH;?>thumbnail.php?pic=<?=$item_details['ad_image'][0];?>&w=350&sq=N&b=N border="0" alt="<?=$item_details['name'];?>">';
    }

    ?>

    I get the following error. Any help would be greatly appreciated

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' at blah blah location line #128

  • #2
    Regular Coder
    Join Date
    Jun 2009
    Posts
    145
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Please use the php tags to post your code,

    Open php using

    PHP Code:
    <?php
    I am going to assume this is line 128, you need to tell us what line is failing..

    PHP Code:
    echo '<img src="<?=SITE_PATH;?>thumbnail.php?pic=<?=$item_details['ad_image'][0];?>&w=350&sq=N&b=N border="0" alt="<?=$item_details['name'];?>">';
    - You have <? tags wrapped inside an already opened php tag...
    - You use single quotes through that line so the outside quotes think you are closing them..

    Something more like this is how it should look (untested)

    PHP Code:
    echo "<img src=\"".SITE_PATH."thumbnail.php?pic={$item_details['ad_image'][0]}&w=350&sq=N&b=N\" border=\"0\" alt=\"{$item_details['name']}\">"


  •  

    Posting Permissions

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