我試圖找出這幾天,我找不到錯誤可能是什麼。我的代碼有些問題,我不知道是什麼,
這是我的代碼:
<?php
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
include 'conn.php';
class get_data extends connection{
public function __construct($page,$rows){
$s_page=mysql_real_escape_string($page);
$s_rows=mysql_real_escape_string($rows);
$this->get_all($s_page,$s_rows);
}
public function get_all($page,$rows){
$this->connect_to_db();
$tablename = $this->define_table_name();
$offset = ($page-1)*$rows;
$result = array();
$rs = mysql_query("select count(*) from $tablename");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$startq="select * from $tablename limit $offset,$rows";
$rs = mysql_query("select * from $tablename limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
}
}
$getdata=new get_data($page,$rows);
?>
輸出爲{"total":"3","rows":[]}
的問題是:行是空的,但它計算有多少行的分貝含義的連接是好的,但查詢行是不是有什麼建議?
查詢後有什麼項目?你可以發佈var_dump()嗎? – 2012-03-06 04:22:08
array(0){}該項目位於項目 – tomexsans 2012-03-06 04:37:07
的var_dump上**檢測到SQL注入** – 2012-03-06 04:39:41