Errors :
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u251789135/public_html/omg/admin/Connection/config.php on line 6
Warning: mysql_connect(): Access denied for user 'U251789135_user'@'10.2.1.35' (using password: YES) in /home/u251789135/public_html/omg/admin/Connection/config.php on line 6 Failed to connect to server: Access denied for user 'U251789135_user'@'10.2.1.35' (using password: YES)
Inside admin/connection dir their are two configurations files .The codes are below :
Config.php : http://pastebin.com/fJiGGCdK
conn.php :
I couldn't paste it here. The editor says it contains code not properly formatted.So i will use paste bin: http://pastebin.com/en2WWquW
I was trying to open admin pages when the error happened. Specifically this : admin/login-exec.php and admin/tracking-exec.php .
Code for admin/login-exec.php :
<?php
//Start session
session_start();
//Include database connection details
require_once('Connection/config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$login = clean($_POST['username']);
$password = clean($_POST['pass']);
//Input Validations
if($login == '') {
$errmsg_arr[] = 'Empty username not allowed';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Empty password not allowed';
$errflag = true;
}
//If there are input validations, redirect back to the login form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
//Create query
$qry="SELECT * FROM admin WHERE username='$login' AND password='$password'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$user = mysql_fetch_assoc($result);
$_SESSION['USER_ADMIN_ID'] = $user['username'];
session_write_close();
header("location: view.php");
exit();
}else {
//Login failed
$errmsg_arr[] = 'Provide a valid user name and password';
$errflag = true;
//If there are input validations, redirect back to the login form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
}
}else {
die("Query failed");
}
?>
Please i need help with fixing the errors. I do not know php. I hope i provided all necessary information.