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