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());
Community
  • 1
  • 1
Aditii
  • 353
  • 1
  • 5
  • 15
  • 2
    How are you connecting to the mySQL database? Are you connecting at all? – Pekka Aug 20 '11 at 18:37
  • Possibly helpful: [Reference: What is a perfect code sample using the mysql extension?](http://stackoverflow.com/q/6198104) – Pekka Aug 20 '11 at 18:38
  • the problem is with the mysql_connect . check the parameters are right. – Mithun Satheesh Aug 20 '11 at 18:39
  • @Aditii Was this caused by the same issue as in [this question](http://stackoverflow.com/questions/7136269/getting-access-denied-error-when-executing-mysql-query-in-php/7136292#7136292) 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. – AgentConundrum Aug 21 '11 at 07:48

3 Answers3

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.

Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • $localhost="localhost"; $username="root"; $password=""; $dbname="shadaab"; $con=mysql_connect("$localhost","$username","$password"); mysql_select_db("$dbname",$con); – Aditii Aug 20 '11 at 19:02
  • append `or die(mysql_error())` to those function like i have shown to see if there is an error. – Sarfraz Aug 20 '11 at 19:07
0

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

Andrej
  • 7,474
  • 1
  • 19
  • 21
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

Joe Flynn
  • 6,908
  • 6
  • 31
  • 44