Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php constant issue

Options
  • 03-07-2004 10:15am
    #1
    Registered Users Posts: 252 ✭✭


    hi i have two files

    File A calls File B passing through the image parameter

    onclick="window.open('viewimage.php?image=G6'

    File B displays the image

    <IMG height=172 src=<?=IMGS?>/<?php echo $_GET; ?>.jpg >

    thats working fine so MY PROBLEM is:

    in file B i have included a file which contains the image title constants
    <? include_once ("english.inc") ?>
    what i want to do is take the image parameter and from that select the right constant (which is named the same as the image)and display it on the page
    define ('G6',"xxxxxxxxxxxxxxxxxxxxx"); is in english.inc

    how do i do that ? because all i can do is echo "G6"??


Comments

  • Registered Users Posts: 9,196 ✭✭✭RobertFoster


    have you put <?php ?> tags in the inc file as it'll just read it in as text/html otherwise.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    I wouldn't store the image names in constants. However, if you do, retrieving them can be done by treating the constant as code to be executed rather than a string variable, using the eval function:
    [PHP]
    <IMG height="172" src="<? eval($_GET); ?>.jpg">
    [/PHP]
    As you can imagine this is highly inadvisable as it is an initiation to a code injection attack. You should store the names as an array instead.


  • Registered Users Posts: 252 ✭✭ConsultClifford


    tnx The Corinthian ill try that - should do it.


Advertisement