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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

php constant issue

  • 03-07-2004 9: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,279 ✭✭✭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