Re: Connecting to MySQL database
| From: | Vitali Falileev | Date: | Fri, 08 Jun 2001 13:09:35 +0000 |
| Subject: | Re: Connecting to MySQL database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70351@lists.php.net to get a copy of this message | ||
Hello David,
Try do not close connection within function B():
function a() {
connect_to_database_A;
connect_to_database_B; // only if you A and B are different
// database type or hosts (!)
run_query;
for(...) {
echo(b(some_data));
}
close_connection_A;
close_connection_B; // see note above
}
function b(data) {
run_query(data);
return (condition ? "good" : "bad");
}
Monday, October 08, 2001, 3:52:45 PM, you wrote:
DO> Hi, small problem :
DO> I have a couple of functions, which, in pseudo-code, do this :
DO> function func_a()
DO> connect to database
DO> run query
DO> for (each line of query)
DO> echo( func_b(some_data) )
DO> close connection
DO> function func_b(some_data)
DO> connect to database
DO> run query(some_data)
DO> if (condition)
DO> return ("good")
DO> else
DO> return ("bad")
DO> close connection
DO> The connect code is identical in both functions (even the variable
DO> names are the same), but the resources aren't declared global
DO> anywhere.
DO> My problem is that when I attempt to close the connection in func_a(),
DO> I get this error :
DO> Warning: 3 is not a valid MySQL-Link resource in C:\Program
DO> Files\Internet\Apache\Apache\htdocs/show_board.php on line 78
DO> Is something stopping me having two connections open at the same time?
DO> djo
--
Best regards,
Vitali mailto:falileev@itos.eu.org