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
Hi twdlewis!
You are outputting a string and not the value of a variable.
Regards,
Günter
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
?>
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!