Forum Moderators: coopster

Message Too Old, No Replies

How to enable MySQL support in PHP?

         

PowerUp

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

10+ Year Member



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"

PHP_Chimp

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

WebmasterWorld Senior Member 10+ Year Member



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

kemikal

6:15 pm on Jul 24, 2007 (gmt 0)

10+ Year Member



Maybe a firewall blocking port 3306?

eelixduppy

6:24 pm on Jul 24, 2007 (gmt 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?

PowerUp

12:08 pm on Jul 25, 2007 (gmt 0)

10+ Year Member



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.

eelixduppy

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



Try this then:

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

the root password is probably what you set.

PowerUp

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

10+ Year Member



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?

eelixduppy

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



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

PowerUp

4:26 pm on Jul 25, 2007 (gmt 0)

10+ Year Member



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.

eelixduppy

5:57 am on Jul 27, 2007 (gmt 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 ;)