Page 1 of 1

unable to connect to mysql

Posted: Thu Dec 27, 2007 7:04 pm
by yacahuma
Hello,


I have being programming with php and mysql for over 9 years and NEVER experienced this problem.


I have php5 , mysql 5 , apache 2 , running on vista(YACC,BLUARG)

I just have the most simple code

Code: Select all

$link = mysql_connect('localhost', 'username', 'password');
and I get a page does not respond message. If I take out that line and replace it with echo "hello" it works.


Is not that it stop working , it is the first time I try it with this installation.

I have oracle xe running and I am able to connect to it.

It puzzles me that I dont get any php error , just and http error from apache. Basically the page is not responding within the time in php.ini

mysql is running fine and I am able to connect using the comannd line.


Any ideas

Posted: Thu Dec 27, 2007 8:51 pm
by Kieran Huggins
Is there some sort of firewall running? Or it could be that Vista is waiting for "authorization" to accept connections or some crap like that.

Posted: Fri Dec 28, 2007 12:31 am
by anjanesh
Vista does ask for this "authorization" for almost everything like regedit, Computer Management etc.
But is it possible to accept this "authorization" in PHP ?

Posted: Fri Dec 28, 2007 2:16 am
by markusn00b
are you doing something like:

Code: Select all

$link = mysql_connect('localhost', 'username', 'password');
if($link){ // connection was successful
    echo "connection established";
} else {
    echo "connection not established";
}
Or are you just leaving the variable as it is?
ie not running it through a function to open the connection?

Just have one line

Posted: Fri Dec 28, 2007 6:45 am
by yacahuma
I just have that one line since I just wanted to test that my php+mysql install was working

Also I disabled the UAC in Vista.

I also try turning off the firewall and the same thing happen, mysql does not respond to php and the php scripts times out.

Posted: Fri Dec 28, 2007 6:47 am
by markusn00b
Well it won't connect if you don't explicity force it to..

Try using the code i provided and see what happens.

:)

New clue

Posted: Fri Dec 28, 2007 8:03 am
by yacahuma
If I run the script from the command line it works. BUT NOT from apache. Can it be the php module???? Weird. And the plot thickens.

Posted: Fri Dec 28, 2007 10:42 am
by Kieran Huggins
I still suspect that the user Apache is running as doesn't have permission to connect to MySQL or crap like that. Is there a place in Vista where you can see a list of authorizations, etc...?

Changing log on

Posted: Fri Dec 28, 2007 2:13 pm
by yacahuma
I went to the services tab and change the log on from my account to "Log on as local system account".

At one time I change that to my account because I was generating some files and wanted to make sure apache will write to my directory.

After changing to "Log on as local system account." I restarted apache and ran again . This time I got a message saying "Apache Http server stopped working and was closed"

Well at least now apache is dying. :evil:

A quick look at the error log and .... the log is empty. Apache die before telling us who or what kill him.

We need Sherlock Holmes!

Re: unable to connect to mysql

Posted: Mon Mar 31, 2008 8:43 am
by bonger
Hi,

Just wondering if anybody has found a solution to this issue? I'm having the same problem with my new Vista laptop. I've never seen this happen on XP though.

I am able to insert into my mysql database but when I try to do a SELECT query I get the message "Apache HTTP server stopped working and was closed".

Any help would be much appreciated.

Cheers.

Re: unable to connect to mysql

Posted: Tue Apr 01, 2008 7:23 pm
by yacahuma
my solution was to eradicate vista from the laptop and install xp.