Hi all,

I've recently discovered the extract function (thanks to the poster 
regarding it), and have found it to save lots of time. 
I'm having a problem though. 99 times out of 100 when someone thinks 
they've found a "bug" it's actually their misuse of the function, so i'm 
pretty sure this is the case with me. Anyway, here's the deal:

I have a function. Inside this function i have

global $name, $type, $location; (and others)

I make a call to a mysql database and get the result in $result.
Then I used to do this:

$name = $row["name"];
$type = $type["type"];
etc.

extract makes this a lot nicer. However, at the end of this function i 
call another function. This also uses the same global variables. Previous 
this worked fine. But now that i'm using extract, while i do have access 
to the variables in the function, i can't get them in the next. 

My guess is that the way extract works, (somehow, who knows), its 
creating a local variable named $name and setting my info to that, as 
opposed to $name = $row["name"] which sets the global. So, even though i 
can access $name in the function, its lost to the next. 
This isn't a huge issue--i can go back to the old way, or pass the 
variables in the function, but there are enough that i wanted to know if 
anyone else has experienced this. Is there some way to tell extract to 
extract the variables and set the results to the global versions?
Maybe i'm way off and its a small code error, but I really do doubt this, 
as i've commented out lines and gone back and forth and get the same 
result. here's the basic idea though:
function tester(){
global $name;
$row = mysql_fetch_array($sql_result);
$name = $row["name"];
nextone();
/*this works fine, but if i have extract($row) and comment out
the $name = $row["name"] line, then i can't see the variable in the 
next function*/

}
function nextone(){
global $name;
echo $name;
}

any ideas?

thanks,
jack



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

Reply via email to