Re: [PHP-DB] global variables

2004-03-02 Thread Torsten Lange
Yes agreed - but you cannot store them in a variable because they will
be lost each time the page reloads. Why not store them in a cookie?
Hello Davey,
thank you for help! I now don't use a cookie but added a column for this 
purpose in my usertable in the db.

Torsten

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


Re: [PHP-DB] global variables

2004-03-01 Thread Richard Davey
Hello Torsten,

Monday, March 1, 2004, 4:48:39 PM, you wrote:

TL I build a small web interface to a database.

This should be on the PHP General list, not DB - but even so, I'll
answer your question:

TL if(!isset($page_no))
TL {
TL $page_no = login;
TL }

TL I declared the $page_no in my
TL #variables.php as
TL $v_dec[page_no] = $page_no.

You don't check $v_dec in your manage.php script though, you check to
see if $page_no is set which it never will be, because no-where do you
give it a value.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html


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



Re: [PHP-DB] global variables

2004-03-01 Thread Torsten Lange
Richard Davey wrote:

 You don't check $v_dec in your manage.php script though, you check to
 see if $page_no is set which it never will be, because no-where do you
 give it a value.
Thanks Davey,
but is $page_no not set every time (see below) or did you mean that I 
must rather use $v_dec[page_no] in the code?

if(!isset($page_no))
 {
 $page_no = login;
 }
$page_no is set to login
if(!(login_status($session_id)) == 1)
   {
   $page_no = login;
   }
$page_no is set to login
if(($user_pid != false)  (login_status($user_pid) == false))
   {
   login($user_pid, $session_id);
   $res_login = 1;
   $page_no = start_select;
If login ok then $page_no is set to start_select.
if(!($page_no == login))
switch {
  case...: $page_no=new value}
Torsten

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


Re: [PHP-DB] global variables

2004-03-01 Thread Torsten Lange
Hello Devey,

 $v_dec[page_no] = $page_no;
 Which means that $v_dec will always equal nothing, because at the
 point at which the file is included, $page_no hasn't been set to
 anything at all.
You mean this will unset $v_dec[page_no]?
This explains why at reload of index.php happens what happend.
But how to solve it? I _have_ to store some variables anywhere.
The session management at this point is rudimentary. I wrote it that 
way, that it works for now, i.e. building the query pages. This is of 
course not the final session management. At login I just write the 
session_id() into the table without checking if the user already owns a 
session. I left it to the end of work. So maybe it is not a problem of 
login_status()?

function check_user($check_name, $check_passw)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
   else
  {
  $sql_check = SELECT count(*) AS count FROM user_web
   WHERE user_name = '.$check_name.' AND user_pass = 
'.$check_passw.';
  $stmt = OCIParse($connect, $sql_check);
  OCIExecute($stmt);

  while(OCIFetch($stmt))
 {
 $res_check = (int) OCIResult($stmt, COUNT);
 }
  if(!$res_check == 1)
 {
 OCIFreeStatement($stmt);
 OCILogOff($connect);
 return(false);
 }
 else
{
$sql_check = SELECT user_pid FROM user_web
  WHERE user_name = '.$check_name.' AND 
user_pass = '.$check_passw.';
$stmt = OCIParse($connect, $sql_check);
OCIExecute($stmt);

while(OCIFetch($stmt))
{
$user_pid = (int) OCIResult($stmt, USER_PID);
}
OCIFreeStatement($stmt);
OCILogOff($connect);
return($user_pid);
}
  }
   }
function login($user_pid, $session_id)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
   else
  {
  $sql_login = UPDATE user_web SET user_session = '.$session_id.'
WHERE user_pid = '.$user_pid.';
  $stmt = OCIParse($connect, $sql_login);
  OCIExecute($stmt);
  }
   OCIFreeStatement($stmt);
   OCILogOff($connect);
   }

function login_status($session_id)
   {
   $connect = @OCILogon(, , );
   if(!$connect)
  {
  $err_oci = OCIError();
  echo (2) No connection - OCIError(): 
nbsp;nbsp;nbsp;.$err_oci[message];
  echo p;
  }
   else
  {
  $sql_session_id = SELECT count(user_session) FROM user_web
WHERE user_session = '.$session_id.';
  $stmt = OCIParse($connect, $sql_session_id);
  OCIExecute($stmt);

  while(OCIFetch($stmt))
 {
 $res_status = OCIResult($stmt, COUNT(USER_SESSION));
 }
  if(!$res_status == 1)
 {
 return(false);
 }
 else
{
return($res_status);
}
  }
OCIFreeStatement($stmt);
OCILogOff($connect);
   }
Now I changed $page_no to $v_dec[page_no] with the same result.
If through submitting a form index.php is reloaded, but the value in 
$v_dec[page_no] get lost.

#manage.php
?php
$session_id = session_id();
include('variables.php');
include('functions.php');
if(!isset($v_dec[page_no]))
   {
   $v_dec[page_no] = login;
   }
if(!(login_status($session_id)) == 1)
   {
   $v_dec[page_no] = login;
   }
/* User logged in? */
if(!($v_dec[page_no] == login))
   {
   include('head.php');
   }
   else
  {
  if(isset($_POST['login']))
 {
 if(!($_POST['user'] == )  !($_POST['passw'] ==))
{
$user_pid = check_user($_POST['user'], $_POST['passw']);
if(($user_pid != false)  (login_status($user_pid) == false))
   {
   login($user_pid, $session_id);
   $res_login = 1;
   $v_dec[page_no] = start_auswahl;
   }
   else
  {
  $res_login = 0;
  $res_login_text = Login incorrect.;
  }
}
else
   {
   $res_login = 0;
   $res_login_text = Insert Login AND Passwort.;
   }
 }
 else
{
$res_login = 0;
}
  if($res_login == 0)
 {
 include('b_login.php');
 }
  }
/* if page = wells,
springs,
precipitation,
surface
used überprüfen, ob Formulare abgeschickt */
if($v_dec[page_no] == start_select)
   {
   if(isset($_POST['b_start_select']))
  {
  if(!($_POST['sources'] == ))
 {
 switch($_POST['sources'])
{
 

RE: [PHP-DB] Global variables

2002-12-10 Thread Ford, Mike [LSS]
 -Original Message-
 From: Jim [mailto:[EMAIL PROTECTED]]
 Sent: 10 December 2002 18:51
 
 Can I define a global variable in a function and then 
 successfully reference 
 it in the rest of the page?

Yes.

(Why didn't you just try it?)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




Re: [PHP-DB] Global variables, $_GET problem

2002-07-24 Thread Andrey Hristov



- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 24, 2002 6:45 AM
Subject: Re: [PHP-DB] Global variables, $_GET problem


 On Wednesday 24 July 2002 11:38, Ruth Zhai wrote:

  We just upgraded our PHP to version 4.2.1.  I realized that $var is no
  longer available from www.url.com/myphp.php?var=3 .  As instructed in
the
  document, we have tried two things:

 Good, someone who reads the docs :)

  1. I tried to use $_GET('var'), however, I got Fatal error: Call to
  undefined function: array() in /home/httpd/...  message.  I have no
clue
  what this means, and what I have done wrong.

 It should be $GET['var'].

It should be $_GET['var']




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




RE: [PHP-DB] Global variables, $_GET problem

2002-07-23 Thread Beau Lebens

Ruth,

your reference to $_GET('var') is close, but as you have seen - no cigar :)
using the () after GET makes it refer to a function, but it is actually an
array which is automatically created, so you need to use

$_GET['var'] (note the square brackets

as for point 2 (register_globals) did you restart the apache service after
changing it? because registering globals should make $var available again
(but won't help with problem 1 :)

HTH

Beau

// -Original Message-
// From: Ruth Zhai [mailto:[EMAIL PROTECTED]]
// Sent: Wednesday, 24 July 2002 11:39 AM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] Global variables, $_GET problem
// 
// 
// Hello php friends,
// We just upgraded our PHP to version 4.2.1.  I realized that 
// $var is no
// longer available from www.url.com/myphp.php?var=3 .  As 
// instructed in the
// document, we have tried two things:
// 1. I tried to use $_GET('var'), however, I got Fatal error: Call to
// undefined function: array() in /home/httpd/...  message.  I 
// have no clue
// what this means, and what I have done wrong.
// 2. Set register_globals = on in the configuration file.  
// This did not make
// any difference.
// 
// I don's know what to do now.  Your help is highly appreciated.
// 
// Ruth
// 
// 
// 
// -- 
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, visit: http://www.php.net/unsub.php
// 

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




Re: [PHP-DB] Global variables, $_GET problem

2002-07-23 Thread Jason Wong

On Wednesday 24 July 2002 11:38, Ruth Zhai wrote:

 We just upgraded our PHP to version 4.2.1.  I realized that $var is no
 longer available from www.url.com/myphp.php?var=3 .  As instructed in the
 document, we have tried two things:

Good, someone who reads the docs :)

 1. I tried to use $_GET('var'), however, I got Fatal error: Call to
 undefined function: array() in /home/httpd/...  message.  I have no clue
 what this means, and what I have done wrong.

It should be $GET['var'].

 2. Set register_globals = on in the configuration file.  This did not make
 any difference.

Did you restart the webserver? 
Did you make sure you're editing the correct php.ini? Check using phpinfo().

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Serocki's Stricture:
Marriage is always a bachelor's last option.
*/


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