Page 1 of 1
stuck. code doesnt work..?
Posted: Fri Mar 05, 2004 11:58 pm
by phice
http://onlygeeks.com/Personal/erm/functions.styles.phps
With my code above, it shows all of the html and what not, but I can't seem to get the $setting variable to work inside the function.
Thanks.
Posted: Sat Mar 06, 2004 12:15 am
by markl999
Try this.
Code: Select all
<?php
error_reporting(E_ALL);
mysql_connect('localhost', 'user', 'pass');
mysql_select_db('blastmb') or die(mysql_error());
$sql = "SELECT name, value FROM bmb_settings";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_object($result)){
$setting[$row->name] = $row->value;
}
function topdef() {
global $setting;
echo <<<EOT
<html>
<head>
<title>{$setting['site_title']}</title>
<base href="{$setting['site_url']}">
<script type="text/javascript" src="scripts/global.js"></script>
<link rel="stylesheet" href="templates/default/styles/default.css" type="text/css">
</head>
<body>
<center>
EOT;
}
function botdef() {
$date = date('Y');
echo <<<EOT
<font style="cursor: default;">2003-{$date} © Blast! Message Boards<br />Brought to you by DevBlast.com</font>
</center>
</body>
</html>
EOT;
}
topdef();
botdef();
?>
You were basically missing, global $setting; inside your function.
Posted: Sat Mar 06, 2004 11:53 am
by McGruff
Couldn't see any code - just a resume page.
Posted: Sat Mar 06, 2004 1:14 pm
by phice
The problem was fixed. I took it offline.