SELECT * FROM dislikes WHERE pid = $post AND uid = $userid AND like = 1;
这个查询不起作用(我不知道为什么)。一旦我使用 mysqli 执行此查询并尝试查找 num 行,我得到
注意:尝试在第 13 行的 C:\wamp\www\include\like.php 中获取非对象的属性
只是让您知道,表不喜欢当前是空的,有 4 列:id、pid、uid 和 like。
编辑:
echo "SELECT * FROM dislikes WHERE pid = $post AND uid = $userid AND like = 1;";
$result = $mysqli->query("SELECT * FROM dislikes WHERE pid = $post AND uid = $userid AND like = 1;");
$row_cnt = $result->num_rows;
这是php代码。第一行的回声输出:
SELECT * FROM dislikes WHERE pid = 2 AND uid = 3 AND like = 1;