my php version is 5.2, which is the old verison. it is because i use the free server it is my website http://driverrecord.hostzi.com/android_login_api/include/profile.php?username=4
i hope someone can help me. the problem may be about the code.
the error message:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'a6578726'@'localhost' (using password: NO) in /home/a6578726/public_html/android_login_api/include/profile.php on line 20
profile.php
// array for JSON response
$response = array();
// include db connect class
require_once dirname(__FILE__). '/DB_Connect.php';
// connecting to db
$db = new DB_CONNECT();
// check for post data
if (isset($_GET["username"])) {
$username = $_GET['username'];
// get a product from products table
$result = mysql_query("SELECT * FROM user WHERE user_id = $username");
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$username = array();
$username["username"] = $result["user_id"];
$username["first_name"] = $result["first_name"];
$username["last_name"] = $result["last_name"];
$username["email"] = $result["email"];
$username["tel"] = $result["tel"];
$username["age"] = $result["age"];
$username["gender"] = $result["gender"];
// success
$response["success"] = 1;
// user node
$response["username"] = array();
array_push($response["username"], $username);
// echoing JSON response
echo json_encode($response);
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No product found";
// echo no users JSON
echo json_encode($response);
}
} else {
// no product found
$response["success"] = 0;
$response["message"] = "No product found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
DB_Connect.php
class DB_Connect {
// constructor
function __construct() {
}
// destructor
function __destruct() {
// $this->close();
}
// Connecting to database
public function connect() {
require_once 'include/config.php';
// connecting to mysql
$con = mysql_connect("XXXXXwebhost.com", "a6578726_driver", "abcde");
// selecting database
mysql_select_db(DB_DATABASE);
// return database handler
return $con;
}
// Closing database connection
public function close() {
mysql_close();
}
}
?>
config.php
<?php
/**
* Database config variables
*/
define("DB_HOST", "XXXXwebhost.com");
define("DB_USER", "a6578726_driver");
define("DB_PASSWORD", "abcde");
define("DB_DATABASE", "a6578726_driver");
?>