SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    reputation consultant ThaVincy's Avatar
    Join Date
    Mar 2003
    Location
    Flanders
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why won't this print?

    Hi all,

    I presume the answer to this question is rather easy for most of you, but I've been trying all sorts of things, and it just won't print:

    Code:
     
    <td valign="top">
    <?php include('picsengine/component/photogallery/home.descp.php'); ?>
    <br><br>
    <?php if (isset($_GET['action'])) { ?> 
    <?php include('picsengine/component/photogallery/home.gallery.php'); ?>
    <?php } ?>
    <?php if (isset($_GET['action']) == '') { ?> 
    <a href="brands.php?category_id=<?php print($_GET['$category_id']); ?>&parent_id=0&lang=<?php print($_GET['$lang']); ?>&action=go"><img src="gui/brand_<?php print($_GET['$category_id']); ?>.jpg" border="0"></a>
    <?php } ?>
    </td>
    The code is supposed to look for the action-variable in the url and use the lang-variable and category_id-variable to complete the href and the img src. Code reads action, but in stead of the image it shows a red cross and the link is missing my lang and category id.

    Url's look like this: brands.php?category_id=1&parent_id=0&lang=nl .

    Thanks in advance for your ideas.
    ThaVincy | redesigning your image
    Twizted Imagebuilding personal and corporate reputation solutions

  2. #2
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you need the ( and ). I usually use echo, not print, I think it's more of a personal preference though.
    ]

  3. #3
    SitePoint Enthusiast elecktricity's Avatar
    Join Date
    Oct 2005
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ga it annoys me when people start and end php tags like that. try this code:

    PHP Code:
    <?PHP
    echo '<td valign="top">';
    include(
    'picsengine/component/photogallery/home.descp.php');
    echo 
    '<br><br>';
    if (isset(
    $_GET['action'])) {
        include(
    'picsengine/component/photogallery/home.gallery.php');
    }
    if (isset(
    $_GET['action']) == '') {
        echo 
    '<a href="brands.php?category_id=';
        echo 
    $_GET['$category_id'];
        echo 
    '&parent_id=0&lang=';
        echo 
    $_GET['$lang'];
        echo 
    '&action=go"><img src="gui/brand_';
        echo 
    $_GET['$category_id'];
        echo 
    '.jpg" border="0"></a>';
    }
    echo 
    '</td>';
    ?>

  4. #4
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or better still:

    PHP Code:
    <?PHP
    echo "<td valign='top'>";
    include(
    'picsengine/component/photogallery/home.descp.php');
    echo 
    "<br><br>";
    if (isset(
    $_GET['action'])) {
        include(
    'picsengine/component/photogallery/home.gallery.php');
    }
    if( empty(
    $_GET['action']) ) { <<<OUT
        <a href="brands.php?category_id=
        
    $_GET['$category_id']
        '&parent_id=0&lang='
        
    $_GET['$lang']
        '&action=go"><img src="gui/brand_'
        
    $_GET['$category_id']
        '.jpg" border="0"></a>'
    }
    OUT;
    echo 
    "</td>";
    ?>
    I've used heredoc code, and also ive used empty() because you don't ask a browser if something is set == ' '.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  5. #5
    reputation consultant ThaVincy's Avatar
    Join Date
    Mar 2003
    Location
    Flanders
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok,

    So I tried both examples of code.

    The second ons keeps giving parse_errors af all kinds.

    The first one displays the page as it should, but the function doesn't work, the link still reads like this in the source:

    HTML Code:
    <a href="brands.php?category_id=&parent_id=0&lang=&action=go">
    <img src="gui/brand_.jpg" border="0">
    </a>
    As you can see, the required info is still missing. For some reason, it seems it doesn't read the variables from the url...

    Any suggestions? Thanks in advance.
    ThaVincy | redesigning your image
    Twizted Imagebuilding personal and corporate reputation solutions

  6. #6
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First try this:

    PHP Code:
    if (isset($_GET['action']) == '') { 
        echo 
    '<a href="brands.php?category_id='
        echo 
    $_GET['$category_id']; 
        echo 
    '&parent_id=0&lang='
        echo 
    $_GET['$lang']; 
        echo 
    '&action=go"><img src="gui/brand_'
        echo 
    $_GET['$category_id']; 
        echo 
    '.jpg" border="0"></a>'
    } else {
        echo 
    "This crappy thing isn't working!!!!!!";

    make sure you replace $_GET['action'] and the 2 $_GET['$category_id']; before you try the code lol. Otherwise, it won't work of course. the 'action' would just be the name of your submit button. Usually it is just submit. If it is action, and the code doesn't echo "This Crappy thing isn't working!!!!" then let us know. That way, we know that 'action' is set, and the variables just aren't getting through.
    ]

  7. #7
    reputation consultant ThaVincy's Avatar
    Join Date
    Mar 2003
    Location
    Flanders
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand really...

    I can't manually replace these variables, because the browser has to read them from the url somehow. The visitor clicks a link, browser navigates, code reads the category_id and the action and displays content accordingly, no?
    ThaVincy | redesigning your image
    Twizted Imagebuilding personal and corporate reputation solutions

  8. #8
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Get the dollar signs out of your $_GET keys.

    $_GET['category_id'] as opposed to $_GET['$category_id'], etc.

  9. #9
    reputation consultant ThaVincy's Avatar
    Join Date
    Mar 2003
    Location
    Flanders
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Offcourse! Stupid me!

    *taps flat hand to forehead*

    Works perfectly! Thanks a billion guys!
    ThaVincy | redesigning your image
    Twizted Imagebuilding personal and corporate reputation solutions


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
  •