Welcome to WebmasterWorld Guest from 3.85.245.126

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to enable MySQL support in PHP?

     
3:56 pm on Jul 24, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Apr 30, 2006
posts:349
votes: 0


Hi, I've tried installing Apache, Php and MySQL for 2 nights now. I've done everything I could find on the internet but I still couldn't get the PHP and MySQL to work properly.

I follow an example in my book to test.

Php code:

<?php
echo mysql_connect ('localhost', 'username', 'password');
?>

And the output on the browser is:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_test.php on line 2

Can anyone help? Thank you.

FYI, phpinfo.php loads fine but also without information about "MySQL"

4:15 pm on July 24, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 12, 2007
posts:766
votes: 0


Are you changing password, host and username to values that will work with the database?
6:15 pm on July 24, 2007 (gmt 0)

New User

10+ Year Member

joined:July 8, 2007
posts:5
votes: 0


Maybe a firewall blocking port 3306?
6:24 pm on July 24, 2007 (gmt 0)

Senior Member

joined:Nov 12, 2005
posts:5967
votes: 0


Try logging into mysql manually through the command line with the same credentials to see if you still have the same problem. Also, which version of mysql are you running?
12:08 pm on July 25, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Apr 30, 2006
posts:349
votes: 0


Are you changing password, host and username to values that will work with the database?

Actually, I don't remember setting up a username or host. I only remember setting a password.

Maybe a firewall blocking port 3306?

I switched off all my firewalls, still the same.

Try logging into mysql manually through the command line with the same credentials to see if you still have the same problem. Also, which version of mysql are you running?

It prompts me for a password. I typed my password, then i see...
Welcome to MySQL monitor....

The MySQL version is 5.0.45-community-nt MySQL Community Edition. I am using windows xp.

1:46 pm on July 25, 2007 (gmt 0)

Senior Member

joined:Nov 12, 2005
posts:5967
votes: 0


Try this then:

mysql_connect ('localhost', 'root', '<password>');

the root password is probably what you set.

3:20 pm on July 25, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Apr 30, 2006
posts:349
votes: 0


Try this then:

mysql_connect ('localhost', 'root', '<password>');

the root password is probably what you set.

It works. You are pro. Thank you.

But why when I run phpinfo.php, I cannot see the information table for MySQL? Is there something I need to change in the php.ini file for it to display this info?

3:24 pm on July 25, 2007 (gmt 0)

Senior Member

joined:Nov 12, 2005
posts:5967
votes: 0


clear your browser cache and view it again to see if anything changes.
4:26 pm on July 25, 2007 (gmt 0)

Full Member

10+ Year Member

joined:Apr 30, 2006
posts:349
votes: 0


clear your browser cache and view it again to see if anything changes.

Hahahaha, you're the man. It works. Everything is good. Now I can move on to the next tutorial. Thank you very much.

5:57 am on July 27, 2007 (gmt 0)

Senior Member

joined:Nov 12, 2005
posts:5967
votes: 0


hehe - sometimes browser cache can make you cause more problems than there already are. you wind up trying to fix things that aren't broken ;)