0

I am getting this warning on line 25:

Warning :
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' >(using password: NO) in C:\xampp\htdocs\shadaab\register.php on line 25

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\shadaab\register.php on line 25 Access denied for user 'ODBC'@'localhost' (using password: NO)"

I have following SQL query on line 25:

$result=mysql_query("SELECT email FROM user WHERE email='$email'")or die(mysql_error());
4
  • 2
    How are you connecting to the mySQL database? Are you connecting at all? Commented Aug 20, 2011 at 18:37
  • Possibly helpful: Reference: What is a perfect code sample using the mysql extension? Commented Aug 20, 2011 at 18:38
  • the problem is with the mysql_connect . check the parameters are right. Commented Aug 20, 2011 at 18:39
  • @Aditii Was this caused by the same issue as in this question that I helped you with earlier? If so, you may want to flag this post for moderator attention (see the "flag" link below your question) and ask them to merge this question with that one. Commented Aug 21, 2011 at 7:48

3 Answers 3

1

The error message means:

  • You have not connected to database (using mysql_connect and mysql_select_db)
  • If you have specified mysql_connect, you are not specifying correct username and password to the mysql_connect function.

Here is how you can connect to your db before running your SQL queries:

$con = mysql_connect('server address', 'username', 'password') or die(mysql_error());
mysql_select_db('your db name') or die(mysql_error());

More information on official documentation.

Sign up to request clarification or add additional context in comments.

2 Comments

$localhost="localhost"; $username="root"; $password=""; $dbname="shadaab"; $con=mysql_connect("$localhost","$username","$password"); mysql_select_db("$dbname",$con);
append or die(mysql_error()) to those function like i have shown to see if there is an error.
0

It seems that you provide invalid data in mysql_connect. Check user/password.

Comments

0

Looks like a connection problem, check that you are calling mysql_connect above that line, and that your settings (password, host name, database name) and permissions are correct. Docs

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.