Click here to Skip to main content
14,640,935 members
Rate this:
Please Sign up or sign in to vote.
See more:
I used a sql statement :
$sql = "DELETE * FROM groups_members WHERE groups_id =" . $groupId . " AND user_id =" . $userId . "";
But it gives me the error : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM groups_members WHERE groups_id =1 AND user_id =4' at line 1. I don't understand why, and it isn't even on line 1...

What I have tried:

I tried putting the variables in {} but it still didn't help. Plz help.
Posted
Updated 2-Aug-20 6:18am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

This
$sql = "DELETE FROM groups_members WHERE groups_id =" . $groupId . " AND user_id =" . $userId . "";
instead of
$sql = "DELETE * FROM groups_members WHERE groups_id =" . $groupId . " AND user_id =" . $userId . "";
should solve the syntax error.

Important: Use parameterized queries to avoid SQL injection.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100