Jump to content

Still Working With My Database And Got A Weird Error Message


dzhax
 Share

Recommended Posts

I am working on my admin cp for a while.When I try to delete a sub_category on my forum, I get this message when I echo mysql_error();MySQL server version for the right syntax to use near 'Topic' at line 1

mysql_query("DELETE FROM `sub_categories` WHERE `sub_categories`.`cat_id` = ". realEscape($_POST['category']) ." AND `sub_categories`.`name` = ". realEscape($_POST['name']));

I know it does not define a connection at the end but, the other queries run just fine so I left it out on this one too.The data im passing through it iscat_id = 6name = Off Topic

Link to comment
Share on other sites

You have to put string values between quotes in the query.Your query prints out to this:

DELETE FROM `sub_categories` WHERE `sub_categories`.`cat_id` = 6 AND `sub_categories`.`name` = Off Topic

It should look more like this:

DELETE FROM `sub_categories` WHERE `sub_categories`.`cat_id` = 6 AND `sub_categories`.`name` = 'Off Topic'

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...