Re: Functions in a .inc file

From: Date: Tue, 18 Jun 2002 03:12:53 +0000
Subject: Re: Functions in a .inc file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-102635@lists.php.net to get a copy of this message
Mark, I can't tell exactly what your function problem is. You may already know this, but make sure your function "exists" in the code before it is called. Also, think of an include just like a big copy/paste operation - the code will execute "inline" so to speak, as if it were in the calling template and not a separate file at all. $db->ConnectToDatabase() is some object oriented syntax. The arrow shows that you're using the ConnectToDatabase function within the object $db. Chris Mark Colvin wrote:
Hi, I have a function (ConnectToDatabase) in an include file that opens a connection to a mysql database. I call this function from another function in the same include file. This doesn't work. If I copy the code from the (ConnectToDatabase) function and paste it into the top of my second function and comment out the call to (ConnectToDatabase) everything works OK. Why is this? I want to have a persistent connection opened so that I don't have to insert the database access code before every call to the database. Also, I'm new to PHP and use this syntax to call my functions : $db->ConnectToDatabase() What does the -> mean? Is this the same as saying $db = ConnectToDatabase() Thanks in advance Mark **************************************************** This e-mail is intended for the recipient only and may contain confidential information. If you are not the intended recipient then you should reply to the sender and take no further ation based upon the content of the message. Internet e-mails are not necessarily secure and CCM Limited does not accept any responsibility for changes made to this message. Although checks have been made to ensure this message and any attchments are free from viruses the recipient should ensure that this is the case. ****************************************************


« previous php.general (#102635) next »