mysql_connect() error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

mysql_connect() error

Post by beckbapegeneral »

someone please give some guidance

Code: Select all

<?php
	$conn = mysql_connect('localhost','root','password');
	if (!$conn)
	{
	  die('Could not connect: '.mysql_error());
	}
	mysql_select_db('ticket');
?>

Code: Select all

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\Program Files\xampp\htdocs\dbconn.php on line 2
Could not connect: Access denied for user 'root'@'localhost' (using password: YES)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there is no user root or that is not the password for it.
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

It would appear that you are supplying incorrect credentials to mysql_connect.


edit::typo
Last edited by ambivalent on Thu Jun 01, 2006 9:42 am, edited 1 time in total.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Sometimes you need to add "@localhost" to the user name ("root@localhost").
Post Reply