当我使用带有预处理语句的SQL select语句时,代码工作正常并在我使用WAMP
服务器在我的计算机localhost中运行时显示内容。
但是当我将此代码上传到我的虚拟主机时。没有任何结果显示或没有任何错误显示。但没有准备好的语句代码在Web托管和显示结果中工作正常。这是我的代码,有和没有准备好的陈述。请告诉我为什么会这样?
准备好的陈述代码。
<?php
for($i=0;$i <$count; $i++){
require('connection.php');
$stmt = $connection->prepare("SELECT * FROM comnt WHERE status = 'Approved' limit 1 offset ?");
$stmt->bind_param('s', $id);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0) {
while($row = $result-> fetch_assoc()){
$pst_content = $row['content'];
$author = $row['name'];
if($i==0){
echo '<div class="item active">';
echo ' <blockquote>';
echo '<div class="row">';
echo '<div class="col-sm-12">';
echo " <p style='color:#a07936'>$pst_content</p>";
echo "<small>$author</small>";
echo ' </div>';
echo ' </div>';
echo ' </blockquote>';
echo ' </div>';
}else{
echo '<div class="item">';
echo ' <blockquote>';
echo '<div class="row">';
echo '<div class="col-sm-12">';
echo " <p style='color:#a07936'>$pst_content</p>";
echo "<small>$author</small>";
echo ' </div>';
echo ' </div>';
echo ' </blockquote>';
echo ' </div>';
}
}
}
}
?>
没有准备好的陈述的代码。
<?php
for($i=0;$i <$count; $i++){
require('connection.php');
$qry = "SELECT * FROM comnt WHERE status = 'Approved' limit 1 offset $i";
$select_cmnt = mysqli_query($connection,$qry);
while($row = mysqli_fetch_assoc($select_cmnt)){
$pst_content = $row['content'];
$author = $row['name'];
if($i==0){
echo '<div class="item active">';
echo ' <blockquote>';
echo '<div class="row">';
echo '<div class="col-sm-12">';
echo " <p style='color:#a07936'>$pst_content</p>";
echo "<small>$author</small>";
echo ' </div>';
echo ' </div>';
echo ' </blockquote>';
echo ' </div>';
}else{
echo '<div class="item">';
echo ' <blockquote>';
echo '<div class="row">';
echo '<div class="col-sm-12">';
echo " <p style='color:#a07936'>$pst_content</p>";
echo "<small>$author</small>";
echo ' </div>';
echo ' </div>';
echo ' </blockquote>';
echo ' </div>';
}
}
}
?>