Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php constant issue

  • 03-07-2004 10:15AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 9,451 ✭✭✭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, Registered Users 2 Posts: 252 ✭✭ConsultClifford


    tnx The Corinthian ill try that - should do it.


Advertisement