Reputation: 1
I have a poke-like application and it doesn't seem to be inserting into the table 'pokes'.
Despite my code looking and seeming fine, it doesnt seem to be showing any sign? Any ideas?
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.";
}
}
Upvotes: 0
Views: 50
Reputation: 250882
In MySQL you would use AND
rather than &&
.
SELECT * FROM pokes WHERE user_to='$username' AND user_from='$added_by'
For the insert, you need to specify the columns to add
INSERT INTO pokes (ColumnA, ColumnB) VALUES ('A', 'B')
To further debug, try checking for errors...
$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
Upvotes: 1