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

How to apply for a new ration card and what are the documents required?

List of documents required for new ration card application in Kerala and how to apply


Application for a new ration card should be addressed to Taluk Supply Officer (TSO) / City Rationing Officer (CRO) of applicant's residing area.

Primary document required are Residence certificate, Income certificate and incase the applicant's name is in another ration card then he/she should submit the reduction certificate ontained from previous TSO / CRO as proof for removing his/her name from old Ration card.

You can get the new application from your currently residing Taluk Supply Office.

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

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