Couple of questions here.. some issues I've personally ran into.. maybe they'll help.
1) Is the function in the same script, or is it in an included script (ie.. a global function script that contains all the functions you define).
2) How are you calling the function... exactly.
3) How are you returning from the function...
The following exapmle should work (I actually use it in several script for clients of mine)
// global.php
<?php
require_once("config.php");
require_once("special.php");
require_once("security.php");
mysql_connect("$db_host","$db_user","$db_passwd") or die("Fatal Error: Unable to connect to mySQL!");
mysql_select_db("$db_name") or die("Fatal Error: Unable to open \"$db_name\" database!");
function get_config($config)
{
$query = "SELECT Config FROM site_config WHERE ConfigName='$config'";
$result = mysql_query($query) or die("Fatal Error: mySQL Query \"$query\"Failed");
$data = mysql_fetch_array($result);
return($data['Config']);
}
?>
// end global.php
// config.php
<?php
$db_host = "localhost"; // mySQL Host System
$db_user = "dbusername"; // mySQL Login Name
$db_passwd = "dbpassword"; // mySQL Login Password
$db_name = "EBAMain"; // mySQL Database Name
$template_table = "template"; // mySQL Templates Table
$default_template = "MainIndex"; // Default Page To Server From index.php
?>
// end config.php
// index.php
<?php
require_once("../EBAMain.Includes/global.php");
$home_url = get_config('Home_URL');
header("Location: ".get_config('Home_URL'));
?>
//end index.php
In this example, my database would have a config table, with the fields Config and ConfigName (where ConfigName=Home_URL and Config=http://www.myhome.com)
The index.php, when loaded in the brosser, would call the function get_config and redirect the visitor to the home_url...
Get it? 🙂 Hope this helps some....