Jump to content

Q on MySQL/PHP


9AF

Recommended Posts

I have recently started to work on MySQL, PHP and apache and I\'m still finding my way round. Having installed apache 2.0.44 (successfully), with MySQL 4.0 and PHP 4.3.2 I found this script which is suppose to help show that all works with PHP/MySQL. The code is:

 

<html>

<head><title></title></head>

<body>

<?php

$host=\"localhost\";

$user=\"pj\";

$password=\"buzz\";

mysql_connect($host, $user, $password);

$db_table = mysql_list_dbs();

for ($i = 0; $i < mysql_num_rows($db_table); $i++) {

echo(mysql_tablename($db_table, $i));

echo(\"

\");

}

?>

</body>

</html>

 

However, I keep on getting this error:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user: \'[email protected]\' (Using password: YES) in C:Program FilesApache GroupApache2htdocstest.php on line 8

mysql test

 

Is this test that I\'m trying to do valid? If so what have I done wrong. Any feedback would be much appreciated.

 

Regards

 

9AF

Link to comment
https://forums.phpfreaks.com/topic/174-q-on-mysqlphp/
Share on other sites

It\'s not your test, it\'s your access that is the problem...

 

You probably have a special password set for the user pj@localhost...

 

That\'s the error anyway... Try and connect with

 

mysql -h localhost -u pj -p buzz from a terminal window...

 

And/Or browse the mysql:user table...

 

Hope this helps,

P.

Thanks for the responses. I have managed to solve the problem by using user \'root\' and a password set to user \'root\'. The PHP code runs fine now. Though I did set a user and a password using mysqladmin for some reason nothing happened (defnitely something to do with permissions). In the documentation it does state somewhere to use user \'root\' when first using a new installation of MySQL as it has all the permissions set already.

 

Thanks again for your help its much appreciated.

 

9AF

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.