これは、情報を取得してajaxに送り返すための私のコードです。
else if(isset($_POST['act']) && $_POST['act']=='getbook'){
$book = normalize_str(htmlentities(preg_replace('/\s+/',' ', $_POST['book']), ENT_QUOTES,'UTF-8'));
$filecat = '../books/'.$book.'/'.$book.'.txt';
$catlist = file($filecat, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$mysqli = new mysqli($Hostname, $Username, $Password, $DatabaseName);
$stmt = $mysqli->stmt_init();
$query = "SELECT `id`,`title`,`price`,`image`,`description`,`category`,`enablerating`,`rating` FROM ".$PapierTableName." WHERE book = ? ORDER BY position ASC, title ASC;";
$prepared = $stmt->prepare($query);
if($prepared){
$stmt->bind_param('s', $book);
$stmt->execute();
$result = $stmt->bind_result($iden, $title, $price, $image, $description, $category, $enrat, $rating);
if($result)
{
$rit = array();
while($stmt->fetch())
{
$rit[] = array(
invert_str(html_entity_decode($title, ENT_QUOTES, 'UTF-8')),
$price,
invert_str(html_entity_decode($image, ENT_QUOTES, 'UTF-8')),
invert_str(html_entity_decode($description, ENT_QUOTES, 'UTF-8')),
invert_str(html_entity_decode($category, ENT_QUOTES, 'UTF-8')),
$enrat,
$rating,
$iden
);
}
$stmt->close();
$count = count($catlist);
$ret = array();
for($i = 0; $i < $count ; $i++)
$ret= array_merge($ret, search($rit, 4, $catlist[$i]));
file_put_contents('tre.txt',print_r($ret,true));
echo json_encode($ret);
}
else
file_put_contents('binderror.txt', $stmt->error);
}
else
file_put_contents('connecterror.txt',$stmt->error);
}
私の問題は$iden
、配列に追加すると機能しなくなることです。つまり、配列がないことを意味します。print_rで印刷すると、出力がありません。(string)$iden
データベースに接続でき、すべての情報がすでにチェックされています(値と存在)
追加情報
なし$iden
。
Array
(
[0] => Array
(
[0] => DB9
[1] => 200031
[2] => //localhost/css/images/objectimg/Aston Martin/db9.jpg
[3] => some html
[4] => DB9
[5] => 1
[6] => 0
)
[1] => Array
(
[0] => Rapid S
[1] => 200000
[2] => //localhost/css/images/objectimg/Aston Martin/vanq.jpg
[3] => some html
[4] => Rapid S
[5] => 1
[6] => 0
)
)。
と$iden
Array
(
)
最後$iden
に:
Array
(
[0] => Array
(
[0] => DB9
[1] => 200031
[2] => //localhost/css/images/objectimg/Aston Martin/db9.jpg
[3] => some html
[4] => DB9
[5] => 1
[6] => 0
[7] => 42
)
[1] => Array
(
[0] => Rapid S
[1] => 200000
[2] => //localhost/css/images/objectimg/Aston Martin/vanq.jpg
[3] => some html
[4] => Rapid S
[5] => 1
[6] => 0
[7] => 45
)
)。