I just created an android app in which app is connected with MySql through PHP files.. I did according to this tutorial this
But I am able to connect when igave localhost address when i gave my server address it is not working .. The following is db_connect .. i didnt make any change
<?php
/**
* A class file to connect to database
*/
class DB_CONNECT {
// constructor
function __construct() {
// connecting to database
$this->connect();
}
// destructor
function __destruct() {
// closing db connection
$this->close();
}
/**
* Function to connect with database
*/
function connect() {
// import database connection variables
require_once __DIR__ . '/db_config.php';
// Connecting to mysql database
$con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
// Selecing database
$db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
// returing connection cursor
return $con;
}
/**
* Function to close db connection
*/
function close() {
// closing db connection
mysql_close();
}
}
?>
db_config.php
<?php
/*
* All database connection variables
*/
define('DB_USER', "root");
// db user
define('DB_PASSWORD', "");
// db password (mention your db password here)
define('DB_DATABASE', "androidhive");
// database name
define('DB_SERVER', "localhost"); // db server
?>
this is the link i uploaded my file...
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/96/11645896/html/app/db_connect.php on line 28 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Warning: mysql_close(): no MySQL-Link resource supplied in /home/content/96/11645896/html/app/db_connect.php on line 42
but message came like this... what I have to do...