Skip to main content

Apache crashed while connecting to MYSQL

I had installed latest WAMP and tried to load a php page which uses a class file.
the class file has code to connect to the Db for fetching records.
When ever the script attempts to make a connection i got the following Error
Window popup in IE and I am not able to do any DB related operation.

Code Sample
-----------------------------------------------------------------
function mysqlConnect(){
//Using Nonpersist connection
$this->_connection=@mysql_connect($this->str_dbServer, $this->str_dbUname, $this->str_dbPass) or $this->returnError("Unable to connect to Database server");
//Using Persist Connection

@mysql_select_db($this->str_dbName,$this->_connection); //Selecting DBASE
}



function mysqlDisconnect(){
// Disconnect the database after dbase access
@mysql_close();
}
----------------------------------------------------------------

How can this be solved?

This is the Err popup message that i got, after this message the browser hangs for few seconds.
----------------------------------------------------
Apache HTTP Server has encountered a problem and needs to close. We are sorry for the inconvenience.
If you were in the middle of something, the information you were working on might be lost.

Please tell Microsoft about this problem.

We have created an error report that you can send to us. We will treat this report as confidential and anonymous.

To see what data this error report contains, click here.
[Send Error Report] [Don't Send]
----------------------------------------------------


Fix to this Issue

This issue is related to the version of PHP. in php version greater that 5, to close a connection we need to specify the connection identifier as its param.

you MUST specify the connection handle.
mysql_close($conenction_handle);

So rewrite the code as

-----------------------------------------------------------------
function mysqlConnect(){
//Using Nonpersist connection
$this->_connection=@mysql_connect($this->str_dbServer, $this->str_dbUname, $this->str_dbPass) or $this->returnError("Unable to connect to Database server");
//Using Persist Connection

@mysql_select_db($this->str_dbName,$this->_connection); //Selecting DBASE
}



function mysqlDisconnect(){
// Disconnect the database after dbase access
@mysql_close($this->_connection);
}
----------------------------------------------------------------

This will work.

Comments

Popular posts from this blog

Payback Points - How to redeem - How to merge multiple payback accounts - Block Payback card - Payback customer care

Your SBI Debit card ending with XX0000 is deactivated only for Internet txn.

SBI account holders may have received an SMS with following message, supposed to be from State Bank of India (SBI).

Your SBI Debit card ending with XX0000  is deactivated only for Internet txn. To activate send SMS "SWON ECOM 0000" to 09223966666. No change for ATM/POS usage
** Replace the four Zeros with last 4 digits of your debit card number

Recently many of the SBI account holder has losed their money due to a hi-tech ATM robbery which happened in Thiruvananthapuram, capital city of Kerala.

Joomla and Forum Integration - Integrating Forums to Joomla

Joomla is one of the most popular CMS opensource packages. It is very easier to develop website's using Joomla. You just need to download Joomla package from Joomla's Official website www.joomla.org  and install it on your domain and later adding customizations to templates and feature and Your website is ready :). Now a days most websites provides a forum section for it users for discussing various article topics, gathering opinions etc.



Following are some best know forum opensource packages which can be integrated with Joomla and create a new forum experience for users


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog