[PHP] Remote file does not return var?

2002-04-15 Thread Imar de Vries

Hi all,

is there any reason why an included remote file does not return a
variable?

I have constructed a login page, where a user can enter his username and
password.

After completion of the form, I include a verification file on a remote
server, that checks the given username and pass with the database on
that remote server.

I have set up the line as follows:

$person_id =
include(http://www.someremoteserver.com/check_login.php?user=$userpass=$pass;)

and in the remote file:

$query = SELECT * FROM persons WHERE per_username='$user' AND
per_password='$pass';
$result = mysql_query($query);

if (mysql_num_rows($result)==1)
{
 $row = mysql_fetch_array($result);
 $person_id = $row[per_id];
 return $person_id;
}
else
{
 return -99;
}


The inclusion was succesful, checking username and pass is succesful,
but returning the variable fails, so the value of $person_id is always
set to 1.

Could this be due to some settings on the remote server, that prevent it
from passing variables back?
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Passing variables with include()

2002-01-14 Thread Imar de Vries

Hi all,

at this moment I am working on a script that calculates standings of our
online racing competition. In order to do that, I have to connect to a
database on a remote server.

I have read in the php manual that

[quote]
When a file is include()ed, the code it contains inherits the variable
scope of the line on which the include() occurs. Any variables available
at that line in the calling file will be available within the called
file. If the include() occurs inside a function within the calling file,
then all of the code contained in the called file will behave as though
it had been defined inside that function.
[/quote]

But for some reason, i simply do not get the script to work. I use a
form in the local script to determine which standings are to be shown,
and the value is stored in $serie_id. This is done in the main scope (no
function used). $serie_id can be 2, 3 or 4.

Then I make an include call to the remote script:

include(http://www.someremote.server/calculate_drivers.php;);

In that remote script I use $serie_id to make a database query. But so
far, the query fails because $serie_id is not known.

Are there any known exceptions (f.i. specific server settings) that
might explain why the variable is not known on the remote server?

Thanks in advance!
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Passing variables with include()

2002-01-14 Thread Imar de Vries

A lot of different answers, which I will respond to:

- The variable is definately set before the include call is made, there is
no doubt about that  at all :)

- Including remote files *is* possible. The php manual does not mention this
does not work, and when I add the variable to the call (include
/calculate_drivers?serie_id=3.php) the code is processed perfectly. The
thing is, I can not pass the variable with the call, because it's value is
determined by the form field. I could use a switch statement of course, but
that adds a lot more text to the code.

- I'm not sure changing the file extension will help (because the code in
that remote php file has to be processed on the remote server, in order to
be able to query the db), but I will give it a try.

--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Passing variables with include()

2002-01-14 Thread Imar de Vries

Imar De Vries wrote:

 - Including remote files *is* possible. The php manual does not mention this
 does not work, and when I add the variable to the call (include
 /calculate_drivers?serie_id=3.php) the code is processed perfectly. The
 thing is, I can not pass the variable with the call, because it's value is
 determined by the form field. I could use a switch statement of course, but
 that adds a lot more text to the code.

I just changed the code to (include
.../calculate_drivers?serie_id=$serie_id.php)

... and this worked! Weird solution...
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] switch-statement overrides use of global arrays?

2001-10-29 Thread Imar de Vries

Christian Reiniger wrote:

 So you want to share the array across *requests*
 That doesn't have *anything* to do with global.

 Have a look at how HTTP works - each request is an isolated execution of
 a PHP script. it doesn't have any idea of what other pages the user
 already looked at. To archieve your stuff you need session management
 (phpbuilder.com has a nice tutorial on this)

Indeed, this is something I only came to know yesterday when Henrik replied
with an answer along the same line: every new instance of the script is
isolated from earlier instances, and therefore does not recognize the array.
I was confused though, because I thought it could be done as I succesfully
transferred other variables. Turned out all those variables were transported
inside a FORM, which does get recognized across multiple instances of the
script.

I'll have a look at documents on session management, thanks for the advice!
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] switch-statement overrides use of global arrays?

2001-10-28 Thread Imar de Vries

Hi all,

a very frustrating problem. For some reason I am not able to pass on an
array between two functions, although I declare it global in both of
them. I suspect my use of a switch statement to control the flow of the
functions is causing some trouble, but I'm not sure. Changing the order
in which I declare the array global did not help, nor the use of
$GLOBALS.

This is a simple representation of what I do:

switch ($action) {
 default:
 main();
 break;
 case test_one:
 test_one();
 break;
}

// ---

function main() {

 $array_test = array();
 global $array_test;

 $array_test[0] = First array, first element;
 $array_test[1] = First array, second element;

 print(Content of first array in the main function is now:br);
 var_dump($array_test);

 print (pform method=\post\ action=\arraytest.php\
enctype=\multipart/form-data\);
 ?
 input type=hidden name=action value=test_one
 input type=submit value=Test tabindex=6
 /form
 ?
}

// ---

function test_one() {

 global $array_test;

// This results in NULL

 print(Content of first array in the first test function is now:br);

 var_dump($array_test);

 $array_test[2] = First array, third element;
 $array_test[3] = First array, fourth element;

// This results in the third and fourth element being shown

 print(pAfter addition, content of first array is:br);
 var_dump($array_test);
}

--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] switch-statement overrides use of global arrays?

2001-10-28 Thread Imar de Vries

Henrik Hudson wrote:

 I would think you would need to define $array_test outside in a global
 environment rather then inside the function since I think/thought it will
 just stay scoped in there and that  global was used to access variables
 which weren't defined inside a functions scope and make it look outside.

 In other words

 //Define GLOBAL
 $array_test = array();

 switch(){
 BLAH
 BLAH

 }

 function main() {
 global $array_test;
 BLAH
 BLAH

 }

 function test_one(){
 global $array_test;
 BLAH
 BLAH

 }

Yes, the only way I could avoid errors that occurred when I tried to manipulate
the array, was to add a $array_test = array(); a few lines before the switch
statement. Alas, this also emptied the array each time I went from one function
to another via the switch statement.

I guess I am trying something that is just not possible (when I insist on using
the switch statement)?
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] switch-statement overrides use of global arrays?

2001-10-28 Thread Imar de Vries

Dl Neil wrote:

 The global array is being defined in the mainline, but not populated. What happens 
if you set element 0 to some
 value (to take up some storage space first) and then try the switched function calls?

This did not produce the desired result, unfortunately. The array is filled correctly 
within the first function,
but is empty after we've passed the switch statement en route to the second function.

 When you say Alas, this also emptied the array each time I went from one function 
to another via the switch
 statement. do you mean that the array definition line is inside the same loop that 
causes the switch statement
 to be revisited?
 (it shouldn't be - put it right at the beginning of the 'mainline' and ensure that 
it is not re-executed (which
 would indeed 'reset' the values))

The array definition line was not inside the same loop as the switch, which it looked 
like of course because there
was a reset at some point, it seemed.

Henriks answer at 23:17 seems to have hit the nail in the head: each time the variable 
$action is changed (using a
FORM), this causes the switch statement to run another function, but this also creates 
a new instance of the
script, in which the variables from the older instance are not known.

I'm now working on a solution that uses the same form to pass on some data I need. A 
bit complex maybe, but I'll
leave the code cleaning for version 2.0 of my software :)
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] One last kick at the cat

2001-10-28 Thread Imar de Vries

Henrik Hudson wrote:

 Inside your function define:

 global $server;
 global $pass;
 global $user;
 etc

 It is using variables insides it's own scope and unless you have use
 GLOBAL_VARIABLES defined in your php.config file, it won't go outside of it's
 scope to look for values, hence they are getting asigned NULL and you can't
 connect to a NULL DB :)

Looking at the content of this post and my post above this one, it seems like it
is global day/night again g
--
Imar de Vries - [EMAIL PROTECTED] - ICQ 6972439



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]