I have completed the whole video and when I view my website I get the following error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/whenther/public_html/connect.php on line 3
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'whenther'@'localhost' (using password: NO) in /home/whenther/public_html/connect.php on line 4
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/whenther/public_html/connect.php on line 4
Can anybody help me out here? I'm not sure where I would have made my mistake.
Originally Posted by . : UrbanMonk : . The mistake is on lines 3 and 4.
Make sure you have your database setup correctly.
No shit,
First of all those are not errors, they are warnings. most "errors" in php are fatal and would kill the script unless handled.
Learn to use warning/error messages. They tell you everything you need.
Warnings in file connect.php on lines 3, 4, and 4 again.
Describes the first 2 warnings as database access denied. therefore you provided the wrong user information and password to be passed to the database, or your database is not set up correctly for the user information you provided.
The third Warning is just informing you that because of the other warnings, it couldnt connect to the database.
At this point no one can really help you without access to your website, code, and database.
if($name&&$comment)
{
$query=mysql_query("INSERT INTO comment (id,name,comment) VALUES ('','$name','$comment')");
}
else
{
echo "Please fill out all the fields.";
}
i am pretty sure the local host part i made bold is a problem.
if anybody who has expereince in this field would like to check my database to see if it has been set up correctly I am happy to give you access to my website.
actually i've got it connecting now. i hadn't made a user or password for my database. but now it just doesn't seem to be sending the comments to my database...
Originally Posted by Chris Burrows Pretty sure it doesn't need one.
Part of the error message includes: (using password: NO) which suggests that I'm not using one, as opposed to an incorrect one.
Well that's because you aren't using one. "" isn't a password, so that counts as not using a password just as much as not having included the parameter at all. Since it said that you weren't using a password, the only possibilities I can think of for the source of that error are either you not using a password for root when you need one (the super likeliest) or there not being a root user at all (not likely).
That is to say that it telling you that you aren't using a password is telling you just that, that you didn't give it a password. That is different from telling you that you're using the wrong password (in which case it would have said "using password: YES".)
It is complete except for 1 thing: When you click "Post Comment" it takes you to an ugly page telling you that you have posted a comment. I want it to just refresh the current page and display the new comment, and empty the text fields.