Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

This
SQL
$sql = "DELETE FROM groups_members WHERE groups_id =" . $groupId . " AND user_id =" . $userId . "";
instead of
SQL
$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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900