0

我有一个类似戳的应用程序,它似乎没有插入到“戳”表中。

尽管我的代码看起来和看起来都很好,但它似乎没有显示任何迹象?有任何想法吗?

if (@$_POST['poke']) {
  $check_if_poked = mysql_query("SELECT * FROM pokes WHERE user_to='$username' AND user_from='$added_by'");
$num_poke_found = mysql_num_rows($check_if_poked);
if ($num_poke_found == 1) {
 echo "Come on! Give the guy a chance!";
  }
 else
 if ($username == $cookie) {
 echo "You cannot Jab yourself.";
 }
 else
  { $poke_user = mysql_query("INSERT INTO pokes VALUES ('', '$cookie', '$username')") or trigger_error(mysql_error());
 echo "$username has been jabbed.";
  }

}

4

1 回答 1

1

在 MySQL 中,您将使用AND而不是&&.

SELECT * FROM pokes WHERE user_to='$username' AND user_from='$added_by'

对于插入,您需要指定要添加的列

INSERT INTO pokes (ColumnA, ColumnB) VALUES ('A', 'B')

要进一步调试,请尝试检查错误...

$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
于 2012-11-15T22:27:08.387 回答