there are a few things wrong with that code. Firstly, the syntax. It should look like this:
function delete()
{
mysql_query("DELETE FROM users WHERE userid='$id'");
}
Secondly, you're within a function. $id isn't defined anywhere within that function, which means your function won't work. Where is $id coming from? Do you have it in the url? If so, then you can use $_GET (a superglobal) to access the value of $id.
mysql_query(DELET FROM users WHERE userid='" . $_GET["id"] . "');
If $id isn't in the url (or being passed using POST method, which is also a superglobal and may be accessed using $_POST["id"]), then you have two options. Pass $id as a parameter in your function, or, define it as global within your function.
// define as parameter
function delete($id)
{
mysql_query("DELETE FROM users WHERE userid='$id'");
}
// or make global within function (if defined in script but outside of function)
function delete()
{
global $id;
mysql_query("DELETE FROM users WHERE userid='$id'");
}
Now if you used the first method, you'd have ot call the function like this
$id = "7";
delete($id);
or
delete("7");
For more reading, have a look here then here
Hope this helps.
Cgraz