I'm using Windows 7 Ultimate, SQL Server 2008 R2, php 5.2.6 I'm new to PHP. I have this file called globalvars.php where global variables are defined.
globalvars.php
<?
session_start();
include_once('database.php');
//global vars
$_APP["SQL_DB_NAME"]="DB_NAME";
$_APP["SQL_DB_SERVER_NAME"]="SERVER_NAME";
$_APP["SQL_DB_USER"]="USERNAME";
$_APP["SQL_DB_PASS"]="PASSWORD";
$_APP["DATE_FORMAT"] = "d-m-Y";
$_APP["TIME_FORMAT"] = "H:i";
//generic function for SQL composition to avoid 's errors
function SQuoteEx($str)
{
return "'" . str_replace("'","''",$str) . "'";
}
function RemoveSQuoteEx($str)
{
return "'" . str_replace("'","",$str) . "'";
}
?>
and i also have this file called database.php where the global vars are called with a snippet function that connects to the SQL Server database:
database.php
function DBConnect($sql,$debug=0)
{
global $_APP;
//connect to db and execute query
$cnn = mssql_connect($_APP["SQL_DB_SERVER_NAME"], $_APP["SQL_DB_USER"], $_APP["SQL_DB_PASS"]) or die(errorHandlingPage(mssql_get_last_message()));
$selected = mssql_select_db($_APP["SQL_DB_NAME"], $cnn) or die(errorHandlingPage(mssql_get_last_message()));
$debug = 0;
//if debug mode echo sql
if ($debug) echo $sql."<br>";
//execute and return rs
$return = mssql_query($sql) or die(errorHandlingPage(mssql_get_last_message()));
if($return){
return $return;
}
}
for some reason the global vars cannot be read by the database.php file. Any ideas what's going on? No message by mssql_get_last_message() was passed. Thank you.
DBConnectfunction?