By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localho

P: 1
Hi,I have index.php which has to connect to database.when ever i was trying to login my database, it is raising the following errors.
1.Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\arnew\backend\dashboard.php on line 15
2.Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\arnew\backend\dashboard.php on line 15
Access denied for user 'ODBC'@'localhost' (using password: NO)
This is My Index.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. if (isset($_SESSION['admin']))
  4.    {
  5. header ("Location: dashboard.php");
  6. } else {
  7. header ("Location: login.php");
  8.    }
  9.  
  10. ?>
This is my login.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title> International Shipping Co.</title>
  9.  
  10. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
  11. <script src="js/jquery.validate.js" type="text/javascript"></script>
  12.  
  13. <!--Initiate form validation - in this example on the login form-->
  14. <script type="text/javascript">
  15. $(document).ready(function() {
  16.     $("#loginform").validate();
  17. });
  18. </script>
  19.  
  20.  
  21. <!--This is the styling for the error message for form validation-->
  22. <style type="text/css">
  23. .error {
  24.     padding: 7px;
  25.     margin: 3px;
  26.     background-color: #FCC;
  27.     border: 1px solid #F00;
  28.     font-family: arial;
  29.     font-size: 10px;
  30.     font-style: normal;
  31.     font-weight: normal;
  32.     font-variant: normal;
  33.     color: #000;
  34.     float: left;
  35.     width: 98%;
  36.     -moz-border-radius:5px;
  37.     -webkit-border-radius: 5px;
  38. }
  39.  
  40. </style>
  41.  
  42. <link href="css/styles.css" rel="stylesheet" type="text/css" />
  43. </head>
  44.  
  45. <body>
  46.  
  47. <div id="admin_wrapper">
  48.  
  49.  
  50.             <form name="loginform" id="loginform" method="POST" action="dashboard.php">
  51.  
  52.  
  53.                     <!--START LOGO  --> 
  54.  
  55.                     <div id="logo">
  56.  
  57.                     <h1><img src="http://bytes.com/topic/php/images/logo1.png"/></h1>
  58.  
  59.               </div>
  60.  
  61.                     <!-- END LOGO -->
  62.                     <p>&nbsp;</p>
  63.  
  64.  
  65.                     <div align="center">
  66.  
  67. <?php
  68. if (isset($_SESSION['success']))
  69. echo "<b>".$_SESSION['success']."</b>";
  70. unset ($_SESSION['success']);
  71. ?>
  72.                     </div>
  73. <br />
  74.                     <label>user name:</label><br />
  75.                     <input name="admin" type="text" class="text large required" id="admin" value="" />
  76.                     <br />
  77.  
  78.               <div class="clearfix">&nbsp;</div>
  79.                     <label>Password:</label><br />
  80.                     <input name="pass" type="password" class="text large required" id="pass" value="" />
  81.                      <br />
  82.  
  83.                        <div class="clearfix">&nbsp;</div>
  84.  
  85.                 <p>
  86.                     <input name="btnLogin" title="Login" type="submit" class="submit" id="btnLogin" value="LOGIN" />
  87.  
  88.               </p>
  89. </form>
  90.  
  91.     </div>
  92.      <div class="container_12">
  93.  
  94.  
  95.  
  96.    <!-- START FOOTER -->
  97.  
  98.         <!-- END FOOTER -->       
  99.   </div><!-- end content wrap -->
  100.  
  101. </body>
  102. </html>
Thsi is my dashbord.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. include("config.php");
  4. if ((isset($_SESSION['admin'])))
  5. {
  6.     $username=$_SESSION['admin'];
  7.     $password1=$_SESSION['pass'];
  8. } else {
  9.     $username=$_POST['admin'];
  10.     $password1=$_POST['pass'];
  11. }
  12.  
  13.     $password=md5($password1);
  14.     $query = "select * from user where username='$username' and password='$password'"; 
  15.     $result = mysql_query($query) or die(mysql_error()) ;
  16.     $result2= mysql_fetch_array($result);
  17.     if($result2)
  18.     {
  19.       $_SESSION['admin'] = $username;
  20.       $_SESSION['pass'] = $password1;
  21.       $_SESSION['user_id'] = $result2['id'];
  22.       $_SESSION['group'] = $result2['gid'];
  23.  
  24. ?>
  25.  
  26. <SCRIPT LANGUAGE="JAVASCRIPT">
  27. window.location="page/list.php";
  28. </SCRIPT>
  29.  
  30. <?php       
  31.     }
  32.     else
  33.     {
  34. $_SESSION['success'] = "Invalid Username/Password!";
  35.  
  36. header ("Location: index.php");
  37.     }
  38. ?>
This my config.php
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. $conn = mysql_connect('localhost', 'root', '****') or die(mysql_error());
  4. mysql_select_db('arnew', $conn) or die(mysql_error());
  5.  
  6. ?>
Nov 14 '11 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
Access denied for user 'ODBC'@'localhost' (using password: NO)
for some reason it doesn’t pass the password for user ODBC.

since you wrote root as user, there is either another call that emits that error or your call is overwritten with some kind of other default values.
Nov 15 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.