Hi, I am unable to pass the value of $var1 to another php program, even though i declared and expected to fill this value of $var1 in runtime.
we modified some configuration settings, but for holiding the variable values and passing, do we need to enable any particular things at configuration.
Maybe you have to set in php.ini "enable globals" (or something like that) and then declare your variables as globals.
You realize the only way you can pass variables it through the URL, a form POST, or through Cookies yes?
And are you refering to them as $_POST['variablename']?
( or GET, SESSION or COOKIE depending on circumstances )
What version of PHP?
I've got the same problem. Say I have a script foo.php with just one line in:
<?php echo $param;?>
If I execute it like
... ... /foo.php?param=1
I'd expect 1 to be echoed, but response is blank. It looks like apache doesn't pass script parameters.
Any idea?
if you have the latest version of PHP, check that register_globals is turned on in the php.ini file. If it is not, either you need to turn it on or you need to access variables through the superglobals such as $GET or $POST.
Example, if you are using GET, instead of using $var1 you would use $_GET['var1'].
You need register_globas on or you need to use Super Globals respectivley. But not sure if this is the case here but you can put the variable names and functions inside a .inc file and include it in the other script and do all of the work in that script and you won't have to pass anything. Saves lots of trouble 🙂
Thanks all, that was most helpful. I've just figured out that register globals isn't a good idea because of security holes. So I go for superglobals like GET POST etc., luckily I've just started a new php project and have got no code to port.
Sometime you save time being a newbie!
lol yea I am learning PHP4 now and I have register_globals on I will have to change that.