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

It generally means your password is wrong

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

Have you checked the permission tables of the database, making sure that the user has access.

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?

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.

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 :)

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.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.