2
有我sqli
请求没有结果..像空的数据。我敢肯定,我的数据库中有多少数据PHP的价值没有结果的mysqli stmt是
这里是我的代码,纠正我,如果我上了错误我的代码
<?php
// include db handler
class DB_Functions {
private $conn;
// constructor
function __construct() {
require_once 'include/DB_Connect.php';
// connecting to database
$db = new Db_Connect();
$this->conn = $db->connect();
}
// destructor
function __destruct() {
}
function getSliderList(){
$stmt = $this->conn->prepare("SELECT cPID, image FROM sliderImage");
$stmt->execute();
if ($stmt->num_rows > 0) {
$result = $stmt->get_result()->fetch_assoc();
$response[] = $result;
$stmt->close();
echo json_encode($response);
return true;
} else {
// user not found
return false;
}
}
}
$x = new DB_Functions();
$user = $x->getSliderList();
$response = Array();
if($user){
$user;
return false;
} else {
$response['error'] = "Sorry an error occured. Our Problem, not you.";
return true;
}
?>
我的数据库请求连接
<?php
class DB_Connect {
private $conn;
// Connecting to database
public function connect() {
require_once 'include/Config.php';
// Connecting to mysql database
$this->conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// return database handler
return $this->conn;
}
}
?>
和config.php
文件
<?php
/**
* Database config variables
*/
define("DB_HOST", "localhost");
define("DB_USER", "bxxx");
define("DB_PASSWORD", "xxxx");
define("DB_DATABASE", "xxxx");
?>
我想结果放入数组..和使用json_encode
在我的应用程序使用它发送此数据...
你有错误报告吗? –
不,没有什么结果,即使是一个错误... –
为什么你准备不需要输入的语句 –