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

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

P: 40
i have a page funtion.php which hs the function to connect to the db

Expand|Select|Wrap|Line Numbers
  1. /* Mysql Connection */
  2. function connect(){
  3.     global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php
  4.     $conn = @mysql_connect($db_server,$db_user,$db_pass) or die("Connection to Database Server Failed");
  5.     @mysql_select_db($db) or die("Database Selection Failed");
  6.     return $conn;
  7. }
  8.  
  9. /* MYSQL QUERY FUNCTION */
  10. function caseQuery($sqlString){
  11.     $conn = connect();
  12.     $rows = @mysql_query($sqlString,$conn);
  13.     @mysql_close($conn);
  14.     return $rows;
  15. }
  16.  
  17. /* MYSQL INSERT QUERY FUNCTION */
  18. function caseInsertQuery($sqlString){
  19.     $conn = connect();
  20.     $rows = @mysql_query($sqlString,$conn);
  21.     $insertId = @mysql_insert_id($conn);
  22.     @mysql_close($conn);
  23.     return $insertId;
  24. }
  25.  
2)i have a page page config.php which has the following code

Expand|Select|Wrap|Line Numbers
  1. $db_server = "localhost"; //Database server
  2. $db_user = "root";                //Database user name
  3. $db_pass = ""; //Database server password
  4. $db = "panchayatsgoa"; //Database Name
  5.  
  6. $filePath = $_SERVER['DOCUMENT_ROOT'].""; //Complete File Path on the webserver Without trailing slash
  7.  
  8. $downloadPath = "downloads"; //This should be in the root directory of the WEBSITE this is a Folder name
  9.  
  10. /* Default Session Time out */
  11. $sessionTimeout = 3600; //Session time out should be specified in SECONDS;

3)i have a page login_attempts.php which hs thecode shown below and which gives me the warning
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\panchayats\admin\login_attempt.php on line 24

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\panchayats\admin\login_attempt.php on line 24

There was an error in selecting login logs

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once "../inc/functions.php";
  3. sessionCheck();
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>Control Panel</title>
  10. <link rel="stylesheet" type="text/css" href="admin.css" />
  11. <script language="javascript" type="text/javascript" src="menu.js"></script>
  12. </head>
  13.  
  14. <body>
  15.  
  16. <h3> Login Attempts</h3>
  17. <?php
  18.     $page = $_GET['page'];
  19.     $records_per_page = 10;
  20.     if (!ctype_digit($page)) $page=1;
  21.     $offset = ($page-1) * $records_per_page;
  22.  
  23.     $getlogs = "SELECT * FROM login_attempts ORDER BY id desc LIMIT $offset, $records_per_page";
  24.     $result = mysql_query($getlogs) or die ("<div style='padding:20px; font-weight:bold; color:#FF0000;'>There was an error in selecting login logs</div>");
  25.     $rows = mysql_num_rows($result);
  26.     if ($rows) {
  27.         echo "<div style='padding-left:20px;'><table style='border-collapse:collapse; border-color:#000' border='1' cellspacing='0' cellpadding='5' width='400'>";
  28.         echo "<tr><td width='100'>IP Address</td><td width='60'>Attempts</td><td width='150'>Time Stamp</td></tr>";
  29.         for($i=1;$i<=$rows;$i++) {
  30.             $res=mysql_fetch_array($result);
  31.             echo "<tr><td>{$res['ipaddress']}</td><td>{$res['attempts']}</td><td>{$res['timestamp']}</td></tr>";
  32.         }
  33.         echo "</table></div>";
  34.         //paging toolbar
  35.         $count_result = mysql_query("SELECT COUNT(*) FROM login_attempts");
  36.         $count_row = mysql_fetch_array($count_result);
  37.         $count = $count_row["COUNT(*)"];        //fetch the total number of rows in the table
  38.         $numofpages = ceil($count/$records_per_page);        // how many pages we have when using paging?
  39.         echo "<div style='margin-left:20px;width:400px;'>";
  40.         if ($numofpages > '1' ) { pagingScript("login_attempt.php", $page, $numofpages); }
  41.         echo "</div>";
  42.     } else {
  43.         echo "<div style='margin-left:20px;'>No Login Attempts</div>";
  44.     }
  45. ?>
  46. </body>
  47. </html>
Jan 15 '10 #1
Share this Question
Share on Google+
5 Replies


dgreenhouse
Expert 100+
P: 250
My first guess is that the server has a password set and you're not providing it in the code...

Expand|Select|Wrap|Line Numbers
  1. db_server = "localhost"; //Database server
  2. $db_user = "root"; //Database user name
  3. $db_pass = ""; //Database server password - MISSING PASSWORD
  4. $db = "panchayatsgoa"; //Database Name
  5.  
Jan 15 '10 #2

P: 40
any idea how i can do dat?
Jan 15 '10 #3

Markus
Expert 5K+
P: 6,050
@lisles
Huh? You do not know your own MySQL server password?
Jan 15 '10 #4

nomad
Expert 100+
P: 664
to find your password look it up on privileges
Jan 18 '10 #5

P: n/a
first Establish the Connection then only it will work
Sep 29 '10 #6

Post your reply

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