0

Hi I'm getting this SQL error, and I'm not seeing what I'm doing wrong...

I'm getting:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM forums WHERE id=2' at line 1

Code:

$remove_forum = "DELETE * FROM forums WHERE id=$selected_option";
$run_remove_forum = mysql_query("$remove_forum") or die(mysql_error());

5 Answers 5

3

It's just DELETE FROM (* is for choosing columns and here you're not choosing any)

Sign up to request clarification or add additional context in comments.

Comments

0

Shouldn't you remove the '*'? As far as I know on standard SQL it is not necessary...

Comments

0

remove * and use DELETE FROM forums WHERE id=$selected_option

Comments

0

WRONG SYNTAX

change

$remove_forum = "DELETE * FROM forums WHERE id=$selected_option";

with

$remove_forum = "DELETE FROM forums WHERE id=$selected_option";

Also I think you could do without quotes when you pass the variable to mysql_query (this way)

$run_remove_forum = mysql_query($remove_forum) or die(mysql_error());

Comments

0

we can use * for only those queries which returns something like select query

1 Comment

Will be fine if you can improve answer quality, with samples or more details which help solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.