i have a page funtion.php which hs the function to connect to the db
2)i have a page page config.php which has the following code
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'@'localho st' (using password: NO) in C:\xampp\htdocs \panchayats\adm in\login_attemp t.php on line 24
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs \panchayats\adm in\login_attemp t.php on line 24
There was an error in selecting login logs
Code:
/* Mysql Connection */
function connect(){
global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php
$conn = @mysql_connect($db_server,$db_user,$db_pass) or die("Connection to Database Server Failed");
@mysql_select_db($db) or die("Database Selection Failed");
return $conn;
}
/* MYSQL QUERY FUNCTION */
function caseQuery($sqlString){
$conn = connect();
$rows = @mysql_query($sqlString,$conn);
@mysql_close($conn);
return $rows;
}
/* MYSQL INSERT QUERY FUNCTION */
function caseInsertQuery($sqlString){
$conn = connect();
$rows = @mysql_query($sqlString,$conn);
$insertId = @mysql_insert_id($conn);
@mysql_close($conn);
return $insertId;
}
Code:
$db_server = "localhost"; //Database server $db_user = "root"; //Database user name $db_pass = ""; //Database server password $db = "panchayatsgoa"; //Database Name $filePath = $_SERVER['DOCUMENT_ROOT'].""; //Complete File Path on the webserver Without trailing slash $downloadPath = "downloads"; //This should be in the root directory of the WEBSITE this is a Folder name /* Default Session Time out */ $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'@'localho st' (using password: NO) in C:\xampp\htdocs \panchayats\adm in\login_attemp t.php on line 24
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs \panchayats\adm in\login_attemp t.php on line 24
There was an error in selecting login logs
Code:
<?php
require_once "../inc/functions.php";
sessionCheck();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Control Panel</title>
<link rel="stylesheet" type="text/css" href="admin.css" />
<script language="javascript" type="text/javascript" src="menu.js"></script>
</head>
<body>
<h3> Login Attempts</h3>
<?php
$page = $_GET['page'];
$records_per_page = 10;
if (!ctype_digit($page)) $page=1;
$offset = ($page-1) * $records_per_page;
$getlogs = "SELECT * FROM login_attempts ORDER BY id desc LIMIT $offset, $records_per_page";
$result = mysql_query($getlogs) or die ("<div style='padding:20px; font-weight:bold; color:#FF0000;'>There was an error in selecting login logs</div>");
$rows = mysql_num_rows($result);
if ($rows) {
echo "<div style='padding-left:20px;'><table style='border-collapse:collapse; border-color:#000' border='1' cellspacing='0' cellpadding='5' width='400'>";
echo "<tr><td width='100'>IP Address</td><td width='60'>Attempts</td><td width='150'>Time Stamp</td></tr>";
for($i=1;$i<=$rows;$i++) {
$res=mysql_fetch_array($result);
echo "<tr><td>{$res['ipaddress']}</td><td>{$res['attempts']}</td><td>{$res['timestamp']}</td></tr>";
}
echo "</table></div>";
//paging toolbar
$count_result = mysql_query("SELECT COUNT(*) FROM login_attempts");
$count_row = mysql_fetch_array($count_result);
$count = $count_row["COUNT(*)"]; //fetch the total number of rows in the table
$numofpages = ceil($count/$records_per_page); // how many pages we have when using paging?
echo "<div style='margin-left:20px;width:400px;'>";
if ($numofpages > '1' ) { pagingScript("login_attempt.php", $page, $numofpages); }
echo "</div>";
} else {
echo "<div style='margin-left:20px;'>No Login Attempts</div>";
}
?>
</body>
</html>
Comment