我有一個問題,使系統,使用戶最喜歡的帖子。我知道我在這裏錯過了一些東西,但我不確定是什麼,也不知道如何修復它,以便它能夠正常工作。最喜歡的帖子腳本
mysql_select_db($database_connection, $connection);
$query_deltakelse = "SELECT brukernavn, postID FROM deltakelse";
$deltakelse = mysql_query($query_deltakelse, $connection) or die(mysql_error());
$row_deltakelse = mysql_fetch_assoc($deltakelse);
$totalRows_deltakelse = mysql_num_rows($deltakelse);
$username=$_SESSION['valid_user'];
if(in_array($_POST['id'], $row_deltakelse))
{
mysqli_query($connection,"DELETE FROM deltakelse WHERE postID='id'");
}
else
{
mysqli_query($connection,"INSERT INTO bruker (brukernavn, postID) VALUES ('$username', '$id')");
}
$(document).ready(function() {
$('.delta').on('click', null, function() {
var _this = $(this);
var post_id = _this.data('id');
$.ajax({
type : 'POST',
url : '/file.php',
dataType : 'json',
data : 'id='+ post_id,
complete : function(data) {
if(_this.text() == 'Fave this')
{
_this.html('Faved!');
}
else
{
_this.html('Fave this');
}
}
});
});
});
<a href="#" class="delta" data-id="<?php echo $post_id; ?>">Favorite</a>
什麼不起作用? –
我得到了一個通知:未定義的索引/變量:ID和警告:mysqli_query()期望參數1是mysqli,資源給出 – dirigibleplum