Its been a while since I used PHP so trying to install some scripts onto my new web host, and the parameters being passed via the URL no longer seem to work.
So the url is basically
a_story.php?called=MyLife
My previous code and web host works fine as I didn't need to use $_GET to access the variable. However I presume things have moved on. However when I update my code so I do
$tmpvar = $_GET['called'];
echo "Storyname=".$tmpvar;
I still get nothing output at all. The host I am with is JustHost, and the only thing I can think that may is preventing me using this is register_globals = off (still reading up on this).
Can anyone help and probably point me to a good tutorial if I need to use an alternative?
Thanks
Getting Parameters from URL
Moderator: General Moderators
Re: Getting Parameters from URL
it should work with register globals off.
the code you posted looks ok, can you post the full php file including php tags?
are you getting an error? or just nothing?
the code you posted looks ok, can you post the full php file including php tags?
are you getting an error? or just nothing?
Re: Getting Parameters from URL
All I have in my file is the html code that displays fine.
Then within the html code I have
<?php
$_SESSION['$called'];
$tmpv = $_GET['$called'];
echo "Called:".$tmpv."<P>";
?>
But nothing is displayed other than "Called:"
Then within the html code I have
<?php
$_SESSION['$called'];
$tmpv = $_GET['$called'];
echo "Called:".$tmpv."<P>";
?>
But nothing is displayed other than "Called:"
Re: Getting Parameters from URL
Here's your error, remove the $.lextar wrote:$tmpv = $_GET['$called'];
You only use $ to specify variable names (and then it still only works in double quotes, if you include it in strings).
called is not a variable name here, but just a key to identify an element in the $_GET array.
On a side note, I don't know why you're doing this:
(It doesn't do anything, and it's wrong)$_SESSION['$called'];
Re: Getting Parameters from URL
to be more specific, remove the final $, remove the $ is vague because there are 3 of them
the correct code is:
the correct code is:
Code: Select all
$tmpv = $_GET['called'];