okay, in login2.php3 it sets a global variable $uname which is the players account name
excerpt..
-->
setcookie(\"usernm\",\"$user\");
setcookie(\"passwd\",\"$pass\");
setcookie(\"login\",\"YES\");
<--
if the user has logged in properly...
in viewscreen.php3 it can read this variable and act on it with database calls such as:
-->
$res = mysql_query(\"SELECT * FROM accounts WHERE account_name=\'$usernm\'\");
$accountinfo = mysql_fetch_array($res);
mysql_free_result($res);
<--
which all works okay, however this means i have to put the database calls etc. in every single script, instead i surmised that i might make a function in functions.php3 to do this for me, so at the top of viewscreen.php3 i have:
-->
GET_VARS();
<--
which is the name of the subroutine and yes, i have added an include to functions.php3 at the top
unfortunately when doing it this way, functions.php3 cannot see anything inside the $usernm variable (that the login2.php3 file created)
function GET_VARS() inside of functions.php3
-->
function GET_VARS()
{
connectdb();
echo \"USERNM = $usernm <BR>\";
echo \"DBASE USERNM = $dbuname <BR>\";
$res = mysql_query(\"SELECT * FROM accounts WHERE account_name=\'$usernm\'\");
$accountinfo = mysql_fetch_array($res);
mysql_free_result($res);
$res2 = mysql_query(\"SELECT * FROM ships WHERE ship_id=\'$accountinfo[current_ship_id]\'\");
$playerinfo = mysql_fetch_array($res2);
mysql_free_result($res2);
if($playerinfo[quadrant_id]==0)
{
$res = mysql_query(\"SELECT FROM quadrant1 WHERE sector_id=\'$playerinfo[sector]\'\");
$sectorinfo = mysql_fetch_array($res);
mysql_free_result($res);
}
else if($playerinfo[quadrant_id]==1)
{
$res = mysql_query(\"SELECT FROM quadrant1 WHERE sector_id=\'$playerinfo[sector]\'\");
$sectorinfo = mysql_fetch_array($res);
mysql_free_result($res);
}
else if($playerinfo[quadrant_id]==2)
{
$res = mysql_query(\"SELECT FROM quadrant2 WHERE sector_id=\'$playerinfo[sector]\'\");
$sectorinfo = mysql_fetch_array($res);
mysql_free_result($res);
}
else if($playerinfo[quadrant_id]==3)
{
$res = mysql_query(\"SELECT FROM quadrant3 WHERE sector_id=\'$playerinfo[sector]\'\");
$sectorinfo = mysql_fetch_array($res);
mysql_free_result($res);
}
else if($playerinfo[quadrant_id]==4)
{
$res = mysql_query(\"SELECT FROM quadrant4 WHERE sector_id=\'$playerinfo[sector]\'\");
$sectorinfo = mysql_fetch_array($res);
mysql_free_result($res);
}
else
{
echo \"<B><H1>DEBUG ERROR: CANNOT GET PLAYERINFO</B></H1><BR>\";
}
$res = mysql_query(\"SELECT FROM ships WHERE sector=\'$playerinfo[sector]\' AND quadrant_id=$playerinfo[quadrant_id]\");
$targetsinsector = mysql_fetch_array($res);
mysql_free_result($res);
if($playerinfo[sector]==0)
{
mysql_query(\"UPDATE ships SET sector=1 WHERE sector_id=0\");
}
echo \"playinfo: $playerinfo[ship_name]<br>\";
echo \"accountname: $accountinfo[account_name]<br>\";
}
<--
any idea why functions.php3 cant see the variable but viewscreen.php3 can?
thanks in advance,