logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



MySQL Close error

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
pips



Joined: 03 May 2006
Posts: 65
Location: Manchester, UK

PostPosted: Thu 15 Feb '07 13:57    Post subject: MySQL Close error Reply with quote

On our internal customer database, I have two files called connect.php and close.php

connect.php:
Quote:
<?php
$dbcnx = mysql_connect('ipaddress', 'username', 'password');
if (!$dbcnx) {
echo '<p>Unable to connect to the guestbook database server at this time.</p>';
exit();
}
?>


close.php
Quote:
<?php
mysql_close($dbcnx);
?>


I then call these two files using the include 'connect.php'; and include 'close.php'; at the appropriate part of the main pages.

However, I am getting the following error message when it executes the close command:-

Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in D:\Apache2\htdocs\443\custdata\close.php on line 2

The data being submitted is being written to the datebase, so there is no problem except for this error message.

I have searched on php.net and I think the problem is that the link is automatically closing itself before I call the close command.

I can suppress the error message using @ before the function name, but I'm wondering if this will suppress other error messages that I may need to know about?

Phil.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Thu 15 Feb '07 15:05    Post subject: Reply with quote

Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.

For a better performance you should use mysql_pconnect
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1