PDA

View Full Version : Custom Global Variables - Please Help


Rory
10-14-2002, 11:42 PM
Hi Iam having a problem that when i include stuff in my phpinclude template the variable is not availabe to any templates. Here is an example:

Here is my phpinclude file :

// This code is PHP4 only:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();

$authed_user = $_SERVER['PHP_AUTH_USER'];

mysql_connect("localhost", "####", "#######");
mysql_select_db("######");

if (!$authed_user) {
exit;
}

$query = "SELECT board_username,board_password from subs where u_name = '$authed_user'";
$result = mysql_query($query);
$make = mysql_fetch_row($result);
$b_username = $make[0];
$b_password = $make[1];

if (!$b_password || !$b_username) {
$b_username = "NoUser";
$b_password = "password";
}

#echo "u:$b_username p:$b_password";
#exit;

When I uncomment the last 2 lines it echos the correct username and password and exits. When I comment the ehco comman and exit out (so it runs through the entire page), the variables arent being replaced on my template. Here is a copy of my username_loggedout template :

<tr valign="top">
<td><input type="hidden" name="username" value="$b_username" size="25">
<input type="hidden" name="password" value="$b_password" size="25"></td>
</tr>

When I view the source of the page the values are showing as "". It seems like it would work but iam obviously doing something wrong. Thansk for the help.

Rory

Rory
10-14-2002, 11:45 PM
Forgot......

I have register globals off, and i have tested with static variables and those arent passed either.

Such as :

$beer = "Hot Sauce";

in the phpinclude template returns NULL when the page is generated.

Steve Machol
10-15-2002, 12:49 AM
Rory, please go to this (http://www.vbulletin.com/members/vbulletin.org.php) page and enter your username, to show you are licensed. (you will need to use your customer number and password to access that page)
Thank you.

Rory
10-15-2002, 12:51 AM
Originally posted by Steve Machol
Rory, please go to this (http://www.vbulletin.com/members/vbulletin.org.php) page and enter your username, to show you are licensed. (you will need to use your customer number and password to access that page)
Thank you.

Done. Thanks.

Rory

Steve Machol
10-15-2002, 12:58 AM
Thanks!

Xenon
10-15-2002, 07:58 AM
you can't use the vars in every template, because some templates are called within a function and you have to globalize this vars in the function before, ... you have to edit functions.php ;)