Jump to content

Still Working With My Database And Got A Weird Error Message


dzhax

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...