unable to connect to mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

unable to connect to mysql

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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 ?
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Post 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?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Just have one line

Post 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.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Post 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.

:)
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

New clue

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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...?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Changing log on

Post 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!
bonger
Forum Newbie
Posts: 1
Joined: Mon Mar 31, 2008 8:36 am

Re: unable to connect to mysql

Post 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.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: unable to connect to mysql

Post by yacahuma »

my solution was to eradicate vista from the laptop and install xp.
Post Reply