Yes, when you build up a SQL query from users input you have to make sure the user didn't write any sh**.
For example: If you want a user to tell you an ID, then you just want a numeric value.
so in your php script you can use
$id = (int) $_REQUEST['id'];
for making sure there is only a number in this variable.
Now make sure this ID in the database is owned by the user and so on.