Hey there,

I'm getting this error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO)

My php code is as follows:

<?php
$con = mysql_connect("localhost","$username","$password"); //Replace with your actual MySQL DB Username and Password
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("formindb", $con); //Replace with your MySQL DB Name
$name=mysql_real_escape_string($POST['name']); //This value has to be the same as in the HTML form file
$email=mysql_real_escape_string($
POST['email']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO formindb (name,email) VALUES ('$name','$email')"; /*form_data is the name of the MySQL table where the form data will be saved.

name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($con);
?>

I'm very green. I recently installed XAMPP.

What am I doing wrong?

Thanks so much!
Beth

    hi. i'm a total noob too - 3 days old i php learning!
    i had a similar prob to yours yesterday, the problem for me was that i hadn't created the database i was wanting to log into!:rolleyes:

    have you definitely used CREATE to set up the database first?

    sorry if this is a dumb answer to ur problem 🙂

      I seems like a server issue. I read that it could be solved using mysql_pconnect() but in my case it didn't help.

      I would appreciate if anyoone can shine some light on this problem...

      Thanks

      TW

        Don't mean to ask dumb questions, but did you replace '$username' and '$password' with the real username and password?

        Right now it is saying that $password is not set. I can only assume that $username is not set either.

        $con = mysql_connect("localhost","database_username","database_password");

          Write a Reply...