Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php cannot connect to mysql

Status
Not open for further replies.

emmons

Technical User
Oct 9, 2002
114
0
0
Here is the php code:

$connect=mysql_connect("localhost:3306","root","mypassword") or die ("Error connecting to MySQL");

if ($connect){
echo "Congratulations!\n<br>";
echo "Successfully connected to MySQL database server.\n<br>";
}else{
$error = mysql_error();
echo "Could not connect to the database. Error = $error.\n<br>";
exit();
}

Here is the output

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in E:\webroot\mysql.php on line 8 Error connecting to MySQL
-------------------------------------
I think php is looking in the wrong directory. mysql.exe is located in e:\mysql. It seems to be looking in e:\webroot and mysql.exe is not in e:\webroot it is in e:\mysql

to connect via command line works fine
e:\mysql>mysql -u username -p

What needs to be done?

Thanks!
Kris
 
it is not looking in the wrong directory, that is the name of my file duh.

Still won't connect though.

I don't know why, maybe you do.
 
Solved. I fat-fingered the password. Can you believe it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top