ここで私はいくつかの値を更新する関数dataLC()を呼び出していますが、ページが実行されるとすぐに関数呼び出し部が実行されませんでした。問題 -php関数が実行されていません
<?php
include 'db.php';
$GLOBALS['lks']=0;
$GLOBALS['cmnts']=0;
echo $GLOBALS['lks'];
echo $GLOBALS['cmnts'];
?>
<div class="btnclasess">
<div id="likescommentID" class="likescomment"><?php dataLC(2); ?><a style="padding-right: 7px" href="#"><?php if($GLOBALS['lks']==0){echo '';}else{ echo $GLOBALS['lks']." Likes"; } ?></a><a href="#"><?php if($GLOBALS['cmnts']==0){echo '';}else{ echo $GLOBALS['cmnts']." Comments"; } ?></a></div>
<div class="pull-left likebtn"><a href="#" onClick="connect(2)"><i class="fa fa-thumbs-up" style="margin-right: 6px;"></i>Like</a></div>
<button class="pull-left btnhideshow show_hide" data-toggle="collapse" data-target="#demo2"><li class="fa fa-comments show_hide" style="margin-right: 6px;"></li>Comment</button>
<button class="pull-left btnhideshow show_hide"><li class="fa fa-share-alt show_hide" style="margin-right: 6px;"></li>Share</button>
<div class="clear"></div>
<div class="clear"></div>
</div>
<script>
function connect(num) {
$.ajax({
type: "POST",
url: "user-likes.php?id="+num,
success: function(data) {
$("#likescommentID").load(" #likescommentID");
}
});
}
</script>
<?php
function dataLC($val)
{
$stmt = $linkID1->prepare("select likes,comments from user_posts where slno=?");
$stmt->bind_param("s", $val);
$stmt->execute();
$stmt->bind_result($lksD,$cmntsD);
$stmt->fetch();
$stmt->close();
$GLOBALS['lks']=$lksD;
$GLOBALS['cmnts']=$cmntsD;
}
?>
誰でも、関数dataLC()呼び出しが機能していない理由を確認できますか?
を '$ linkID1'が定義されている場合は?エラー報告を使用する必要があります。 include 'db.php'内の – chris85
。 –
範囲の問題 – nogad