|
Posted by PSI_Orion on 07/28/06 16:51
Is it possible to have functions in include files? I am trying to generate
a global function include for opening my databases but it comes back and
says:
Fatal error: Call to undefined function dbaseConnect() in
D:\Inetpub\wwwroot\psiss.com\dummy\index.php on line 19
The include file is this...
<?
if(!(include 'XXXXXXXXX'))
die("<p align='center'><font color='#FF0000'><b>FAILED TO INCLUDE
'XXXXXXXXX'</b></font></p>");
function dbaseConnect($dbaseName,$tableName)
{
$dbase=@mysql_connect($dbaseName,$dbaseUser,$dbasePW);
if(!$dbase)
die("<p align='center'><font color='#FF0000'><b>ERROR CONNECTING TO MySQL
SERVER</b></font></p>");
$tables=@mysql_list_tables($tableName,$dbase);
if(!$tables)
die("<p align='center'><font color='#FF0000'><b>ERROR RETRIEVING TABLES
FROM DATABASE '".$dbaseName."'</b></font></p>");
$FOUND=false;
for($i = 0; $i < @mysql_num_rows($tables) && (!$FOUND); $i++)
{
if(@mysql_tablename($tables,$i) == $tableName)
$FOUND=true;
}
if(!$FOUND)
die("<p align='center'><font color='#FF0000'><b>ERROR RETRIEVING TABLE
'".$tableName."'</b></font></p>");
}
?>
and the include stuff in the main file is this which is declared before the
dbaseConnect() call.
if(!(include 'XXXXXXXXXXX'))
die("<p align='center'><font color='#FF0000'><b>FAILED TO INCLUDE
'XXXXXXX'</b></font></p>");
dbaseConnect("xxxxxxx","xxxxxxx");
Obviously, for security reasons, I've changed the file names in this code to
XXXXXXXXXX.
--
With kindest regards
************
PSI_Orion
************
http://www.psiss.com
[Back to original message]
|