Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #290166

    I program in codfusion, c etc – I find php & wordpress quite miserable. I cannot work out how within a page to do the most basic thing of looking for a variable, setting it if it doesn’t exist, and then putting that value into a url link.

    I have installed PHP Execute. Why doesn’t this work? Thank you

    <?php if( isset($_GET[‘UserID’]) ){ $myUserID = $_GET[‘UserID’]; } else { $myUserID = rand(1, 10000); } ?>

    <?php echo ‘*** $myUserID ***’?> // just echos the variable name

    // userid=blank

    #290176

    Hi twdlewis!

    You are outputting a string and not the value of a variable.

    Regards,
    Günter

    #290185

    Thanks – however I got the numbver to work but no permutation will make the url string work…

    <?php
    $myUserID = 123;
    echo $myUserID; // ok
    $myUrl="www.domain.com/pagename/?uid=".$myUserId;
    echo $myUrl; // shows ?uid= blank
    $myUrl='www.domain.com/pagename/?uid='.$myUserId;
    echo $myUrl; // shows ?uid= blank
    $myUrl="www.domain.com/pagename/?uid=$myUserId";
    echo $myUrl; // shows ?uid= blank
    ?>

    • This reply was modified 10 years, 4 months ago by twdlewis.
    #290193

    Hey!

    php is case sensitive !!
    $myUserID != $myUserId

    Regards,
    Günter

    #290195

    Well that explains a lot! In 20 years I have never used a case sensitive variable language, and my eyesight is pretty bad too, so thanks!

    #290401

    Hey!

    Glad we could help you.

    Best regards,
    Günter

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘php in page’ is closed to new replies.