views:

64

answers:

1

Hi all...

I have a table with the following structure....

    FIELD           TYPE          EXTRA
faciltiy_id         int          auto_increment(Primary Key)
hotel_id            int
facility_title      varchar(20)
facility_desc      varchar(300)

When i want to delete a row with a particular facility_id i use the code....

DELETE 
FROM   $hotel_facilities
WHERE  facilities_id = '$facilities_id'";

But instead of the whole row, only the facility_title and facility_desc fields are getting deleted. If I run this query directly through phpmyadmin over the table it works correctly...

Can anyone enlighten me on what i am doing wrong...???

Thanks a lot in advance...!

+1  A: 

But instead of the whole row, only the facility_title and facility_desc fields are getting deleted. If I run this query directly through phpmyadmin over the table it works correctly...

Because the facilities_id is an INT, you don't need to enclose it within single quotes:

DELETE FROM {$hotel_facilities}
 WHERE facilities_id = {$facilities_id}

But I think the real issue is that an UPDATE statement is being called, rather than the DELETE statement. Mainly because a DELETE statement only deletes entire rows, not specific columns.

You need to trace over what is being called when the submit is triggered, and print to screen (either using echo or via Javascript if it's more convenient) prior to execution.

OMG Ponies
Thanks a lot OMG.... just a stupid "forgot-$-before-variable" mistake... and the wrong condition got executed..!! Thanks....
SpikETidE