RE: (newbie)calling GLOBAL arrays
| From: | Bobby Rahman | Date: | Sun, 23 Mar 2003 19:27:05 +0000 |
| Subject: | RE: (newbie)calling GLOBAL arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140770@lists.php.net to get a copy of this message | ||
Hiya
Im having difficulties calling array values from outside script.
I have db.api.php
<?
session_start();
function db_fetch($querystring)
{
$db_result = mysql_query($querystring);
$row = mysql_fetch_row($db_result);
session_register('row');
$username = $row[0];$password = $row[1]; $email = $row[2];
echo "THE USERNAME IN DB.API IS $username";
echo "THE PASSWORD IN DB.API IS $password";
echo "THE EMAIL IN DB.API IS $email";
}
?>
// this works fine but now when I try and call these variables from
// another php script user.api.php
<?
session_start();
require_once("db_api.php");
$querystring = ("select username, password , email
from user where username= '$username'");db_fetch($querystring); echo "THE USERNAME IN USER API2 IS $row[0]"; echo "THE PASSWORD IN USER API IS $password"; ?> // I have tried to print to screen these variables from the //global array $row two different ways and seem to get nothing on screen // I have also tried registering the variables seperately such as session_register('username'); with no luck Can anyone see what I am doing wrong or suggest any tutorials which may describe using arrays with sessions. Thanks _________________________________________________________________ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parental&pgmarket=en-gb&XAPID=186&DI=1059