You are here: Functions in Include Files « All PHP « IT news, forums, messages
Functions in Include Files

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация