[PHP-DB] global vars

2002-10-30 Thread Tomas Kubis
Hello,
 I have big problem. I upgraded PHP from 4.1.2 to 4.2.3 and my scripts with
doesn´t work. Please help me!
in php.info register globals=On

For example I have one script:
first.php
?
global $a;
$a=150;
Header(Location: second.php);
?

second.php

?
echo $a;
echo $GLOBALS['a'];
echo END;
?

Where I have a bug?

Thank you very much

Tomas Kubis



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




Re: [PHP-DB] global vars

2002-10-30 Thread David Smith
When you redirect, you lose your variables. This means that you must
send them in some form to the other script. If you change your redirect
command to the following, you will see that $a gets transferred and
echoed in the second script as well as the first:

Header(Location: second.php?a=$a);

Note: this only works if you have register globals on which you seem
to have, so it should fix your problem.

Good luck!

--Dave


On Wed, 2002-10-30 at 23:05, Tomas Kubis wrote:
 Hello,
  I have big problem. I upgraded PHP from 4.1.2 to 4.2.3 and my scripts with
 doesn´t work. Please help me!
 in php.info register globals=On
 
 For example I have one script:
 first.php
 ?
 global $a;
 $a=150;
 Header(Location: second.php);
 ?
 
 second.php
 
 ?
 echo $a;
 echo $GLOBALS['a'];
 echo END;
 ?
 
 Where I have a bug?
 
 Thank you very much
 
 Tomas Kubis
 
 
 
 -- 
 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 vars

2001-03-28 Thread olinux

nevermind, sorry
it was a stupid comma in my sql query...
what i have is very sool tho, so if you would like the script its great!
i derived it, almost entirely from Dan LaFlamme's NOT working script at
http://phpbuilder.com/columns/laflamme20001016.php3

olinux

- Original Message -
From: "olinux" [EMAIL PROTECTED]
To: "PHP-DB" [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, March 28, 2001 2:06 PM
Subject: [PHP-DB] global vars


I am working with global variables and functions, specifically calling a
function inside another function.
I checked the online docs and don't see any problems with what i have... i
declare the table_name as global inall functions

What I am trying to do is DELETE all entries for a uid before INSERTING the
new skills
my insert_skills() calls the function to DELETE entries and then the
function that creates the INSERT query

the lookup_skills table columns looks like this.
   |   id   |   uid   |   skills_id   |


here are a couple excerpts from my code:

table_name = "lookup_skills";
...

function insert_skills($uid, $skills) {
global $table_name;
   purge_lookup($table_name, "1");

   $query = create_checkbox_query($skills, $table_name, "1");

...

function purge_lookup($table, $uid) {
global $table_name;
  $q = "DELETE FROM $table, WHERE uid = $uid";
  mysql_query($q);
}

...

function create_checkbox_query($arr, $table, $uid) {
global $table_name;
   $q = "INSERT INTO $table (uid, skill_id) VALUES";
   foreach ($arr as $check) {
 $q .=  " ( $uid , $check )" . ",";
   }
   return substr($q, 0, -1);
}

insert_skills("1", $skills);

thanks much,
olinux




_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP Database 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]