0

my code is following

<?php
	$conn = mysql_connect("localhost","rentwall_rentwal",")X7zlBx)XgZ5") or die ("Could not connect MySQL");
	mysql_select_db('rentwall_rentwall',$conn) or die ("Could not open database");
function post($postname)
{
	$posted = mysql_real_escape_string($postname);
	return $posted;
}
?>

it gives notification that

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'rentwall_rentwall'@'localhost' (using password: YES) in C:\wamp\www\site2\db.php on line 3
Couldnot Connect MySQL

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

5
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by phorce
0

I had a similar problem due to weird characters, make sure that every character in your password is correct.

0

Could you please explain this:

$conn = mysql_connect("localhost","rentwall_rentwal",")[B]X7zlBx)XgZ5"[/B]) or die ("Could not connect MySQL");

What is X7zlBx)XgZ5?

0

Could you please explain this:

$conn = mysql_connect("localhost","rentwall_rentwal",")[B]X7zlBx)XgZ5"[/B]) or die ("Could not connect MySQL");

What is X7zlBx)XgZ5?

I believe that this is the password for that user to access the database, it looks dodgy to me as well, but could be acceptable.

0

But surely:

$conn = mysql_connect("host","username", "password") or die ("Could not connect MySQL");

To me, your connection string is wrong and therefore cannot connect :)

0

The entire line is correct, it has to be one of the three variables being passed to mysql_connect(). Or privileges for the user. A simple way to check this is to log into the SQL Server directly using that password and username.

If you are able to log in with them details and the Database is on localhost, there might be another problem of the PHP not being able to talk to the database. Check the port numbers in php.ini file match the ports that the database is listening to, and the location of 'mysql.sock', is where the php.ini files tries to look for it.

Manual for mysql_connect()

But the line of code looks fine.

0

The entire line is correct, it has to be one of the three variables being passed to mysql_connect(). Or privileges for the user. A simple way to check this is to log into the SQL Server directly using that password and username.

If you are able to log in with them details and the Database is on localhost, there might be another problem of the PHP not being able to talk to the database. Check the port numbers in php.ini file match the ports that the database is listening to, and the location of 'mysql.sock', is where the php.ini files tries to look for it.

Manual for mysql_connect()

But the line of code looks fine.

Just looked at the line again, it's confusing but it looks to be okay.. My bad ;) it's late!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.