Talent87 Posted September 15, 2009 Share Posted September 15, 2009 Hi, can any one help me with this , I have used this code to connect to mysql data base but it gives me the error message that I put it down the code, I have no named the login and password to MySQL data base the version of wampserver that I have installed is 2.0 thanks<?php$con = mysql_connect("localhost","","");if (!$con) { die('Could not connect: ' . mysql_error()); }if (mysql_query("CREATE DATABASE my_db",$con)) { echo "Database created"; }else { echo "Error creating database: " . mysql_error(); }mysql_close($con);?>-------------------------------------------------------------------Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\CreateDB.php on line 3Could not connect: Access denied for user 'root'@'localhost' (using password: YES) Link to comment Share on other sites More sharing options...
jlhaslip Posted September 15, 2009 Share Posted September 15, 2009 Check that the User-name and password are correct. Also check with your Hosting company that"localhost" is correct. Some Hosts use different values. Link to comment Share on other sites More sharing options...
Talent87 Posted September 16, 2009 Author Share Posted September 16, 2009 Also I have did what you said in mysql privilge I changed my user name and pass but was not successful Link to comment Share on other sites More sharing options...
dsonesuk Posted September 16, 2009 Share Posted September 16, 2009 you usually have to provide host "localhost", location "(usually 'root')", and password "yourpassword".so try$con = mysql_connect("localhost","root","yourpassword"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.