Page 1 of 1
[SOLVED] now it is a register_global problem :)
Posted: Thu Jun 17, 2004 8:21 am
by dethron
Hi everyone;
I have 3 servers, and I'm trying to get some communication between them. Here is the scenario;
SERVER 1
it contains fname1.php which is as follows;
Code: Select all
<?php
if($mVar == 2)
echo "This is second server";
else if($mVar == 3)
echo "This is third server";
else
echo "This is first server";
?>
SERVER 2
it contains fname2.php which is as follows;
Code: Select all
<?php
$file_adr = "http://server1/fname1.php?mVar=2";
$content = file($file_adr);
?>
SERVER 3
it contains fname3.php which is as follows;
Code: Select all
<?php
$file_adr = "http://server1/fname1.php?mVar=3";
$content = file($file_adr);
?>
But when i open fname2.php and fname3.php in my browser, I get different content.
So I think this stems from configuration of my servers.
While server 2 succesfully parse the file an create an output
"This is second server", server 3 gives "This is first server".
Here is the versions of the installed PHP on servers.
SERVER 2 : PHP Version 4.3.3
SERVER 3 : PHP Version 4.2.2
Thnx a lot.
Posted: Thu Jun 17, 2004 10:02 am
by Weirdan
at least you need to change your conditions to use comparison operator instead of assignment:
Code: Select all
// was:
if($mVar = 2)
//should be:
if($mVar == 2)
Posted: Thu Jun 17, 2004 10:57 am
by dethron
Ok. let it be so,
The problem is not just a simple syntax error or something like that.
I just simplified the problem as above.
The main problem is file() function.
When the file,which will be parsed using file() function, outputs differently according to given parameter,
one server takes parameter in file() function, and the other doesn't.
But again, thanks for help.
Posted: Thu Jun 17, 2004 10:58 am
by dethron
As Weirdan points, there is a simple mistake. But the problem is the same.
I edited my first post to correct this simple mistake.
Posted: Thu Jun 17, 2004 11:02 am
by markl999
It's weird. It sounds like a register_globals problem but it can't be as SERVER1 should exhibit the same behaviour regardless of where it's called from. The only way i can see it being a SERVER2 vs SERVER3 register_globals problem is if the mVar variable in those url's isn't actually hard coded (as in your examples) but is coming from 'somewhere else' *shrug*
Posted: Thu Jun 17, 2004 11:33 am
by feyd
have you tried this with [php_man]curl[/php_man]? Have you tried echoing the request uri ($_SERVER['REQUEST_URI']) on Server1?
Posted: Thu Jun 17, 2004 1:22 pm
by dethron
yes i did it, the URL is correct for both request.
by the way, i used
Code: Select all
<?php
//echo $mVar;
$register_globals = (int) ini_get('register_gobals');
echo $register_globals;
?>
and both servers returned 0. So the possibility for global variables become 0

i've been working on for 10 hours. And finally found that the problem is in Server 3 exactly.
Since some shared accounts responds as Server 2, and this is what should be, i got this idea.
I will do some tests on Server 3, and will find another model(scenario) which is simpler to solve.
Thanks for anyone
Kind Regards.
Posted: Thu Jun 17, 2004 2:16 pm
by dethron
He he, finally i found the exact problem.
However I just specify the problem. Solution still seems to be a mystery.
I uploaded a file to Server 3 which is as follows;
//****an.php*****
And send the following request
http://Server3/an.php
as we expected, nothing happened.
When i send the following request, what I see as an output is very interesting.
http://Server3/an.php?mVar=testvalue
Then the output is nothing.
Gentelmen, I'm sure many of you faced with such a problem,
I'm expecting your solutions
Kind Regards.
Posted: Thu Jun 17, 2004 2:27 pm
by feyd
well.. if register_globals is off.. that won't say anything.. $_GET['mVar'] would, however.
Posted: Thu Jun 17, 2004 5:34 pm
by dethron
Hmmm, yes it is worked, thank you all.
But now, a new problem occured.
Since $mVar is sent by both post and get method, in the script I can't know the way that variable sent (Am I right, I'm not sure.)
What if I use $_GET['mVar'] when the variable sent by a form?
Should I enable the register_globals?
Posted: Thu Jun 17, 2004 5:38 pm
by markl999
Use $_REQUEST['mVar']; then it won't matter if it's sent by get or post.
Posted: Thu Jun 17, 2004 5:42 pm
by dethron
He he, finally it solved.
Thx for everyone.