GarrettChristopherson
asked on
error when attempting to connect to MySQL with PHP
I am using Windows Small Business Server 2003 with IIS 6.0. I am attempting to connect to a mysql database using the following code:
$conn = mysqli_connect('192.168.1. x', 'root@localhost', 'password', 'database');
I have also created another user account, and provided all privileges to the account in the MySQL client. I then tried connecting with the new user account with the same error message
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'root@localhost'@'cogent-s 1.CogentMe dia.local' (using password: YES) in C:\StuffLocator\email_veri fication.p hp on line 20
Access denied for user 'root@localhost'@'cogent-s 1.CogentMe dia.local' (using password: YES)
I have checked the php.ini to ensure that the extension=php.mysqli.dll is uncommented and that the php.mysql.dll is in the extensions folder.
I appreciate all help that can be provided.
$conn = mysqli_connect('192.168.1.
I have also created another user account, and provided all privileges to the account in the MySQL client. I then tried connecting with the new user account with the same error message
Warning: mysqli_connect() [function.mysqli-connect]:
Access denied for user 'root@localhost'@'cogent-s
I have checked the php.ini to ensure that the extension=php.mysqli.dll is uncommented and that the php.mysql.dll is in the extensions folder.
I appreciate all help that can be provided.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
t tried the following code:
$localhost = 'localhost';
$username = 'root';
$password = 'ljfs531ljfs531';
$database = 'test_001';
$conn = mysql_connect('$localhost' , '$username', '$password');
mysql_select_db($database, $conn);
and received the following errors:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host '$localhost' (11004) in C:\StuffLocator\email_veri fication.p hp on line 24
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\StuffLocator\email_veri fication.p hp on line 25
This was using the older mysql_connection. any ideas
$localhost = 'localhost';
$username = 'root';
$password = 'ljfs531ljfs531';
$database = 'test_001';
$conn = mysql_connect('$localhost'
mysql_select_db($database,
and received the following errors:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host '$localhost' (11004) in C:\StuffLocator\email_veri
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\StuffLocator\email_veri
This was using the older mysql_connection. any ideas
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, now I have other problems with other sections of the code, but at least I'm connecting now. thanks for your help!
Welcome, I am happy to assist you.
ASKER
I tried using variables instead of place just the values into the mysqli_connect method:
$localhost = 'localhost';
$username = 'root';
$password = 'password';
$database = 'db';
$conn = mysqli_connect('$localhost
and got this error:
Warning: mysqli_connect() [function.mysqli-connect]:
Unknown MySQL server host '$localhost' (11004)
Is there something that I have to do in the MySQL client to get the localhost linked to the database?