我试图登录到我的应用程序,这是我得到的错误:应用程序崩溃后,我尝试登录
08-28 07:57:31.450: E/JSON(1047): <br />n<b>Warning</b>: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known.
in <b>C:\xampp\htdocs\API\include\DB_connect.php</b> on line <b>19</b><br />n<br />n<b>Warning</b>: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known.
in <b>C:\xampp\htdocs\API\include\DB_connect.php</b> on line <b>19</b><br />nNo database selectedn
08-28 07:57:31.450: E/JSON Parser(1047): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
它看起来像它没有连接到数据库成功,但是我不”不明白为什么。
此外,这是我的index.php
文件,该文件位于xampp/htdocs/api
:
这是config.php
文件:
<?php
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "");
define("DB_DATABASE", "dbapp");
?>
的db_connect.php
文件:
<?php
class DB_Connect {
// constructor
function __construct() {
}
// destructor
function __destruct() {
// $this->close();
}
// Connecting to database
public function connect() {
require_once 'config.php';
// connecting to mysql
$con = mysql_connect('DB_HOST', 'DB_USER', 'DB_PASSWORD');
// selecting database
mysql_select_db('DB_DATABASE');
// return database handler
return $con;
}
// Closing database connection
public function close() {
mysql_close();
}
}
?>
这是错误的,你只需要使用'require'导入文件'config.php'并在你的文件 – Sal00m 2014-08-28 09:18:41