Unable to perform a delete from MySQL Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gilimi
Forum Newbie
Posts: 2
Joined: Thu Jul 10, 2003 4:44 pm

Unable to perform a delete from MySQL Database

Post by Gilimi »

Good Day all,

I know that this should be a simple task, but for some reason I cannot get it to work without an error.

I have a table with three fields, index an autoincrement number, date (a date) and text that holds just general garble) I worte a PHP script that creates a form and each entry is assigned to a radio button. The idea is that the user will select the radio button of the entry s/he wants to delete. Now the value of the radio button is set to the index value of the row it is being generated from.

Now when they click the delete record button, the index value is correctly passed to the delete script. I generate a query that looks like this:

DELETE FROM rants WHERE 'index' = '$index'

I don't get a PHP or MySQL error but it returns 0 rows indicating that it did not delete the record. I have printed out the generated query and all looks fine. What am I missing here to get a record deleted?

Any help is greatly appreciated.

Warm Regards,
Joe
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Try this:

Code: Select all

DELETE FROM rants WHERE index='$index'
Not sure if that will fix it but its worth a try.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

:!:

I just want to add that there is a Database forum for a reason.

:!:
Gilimi
Forum Newbie
Posts: 2
Joined: Thu Jul 10, 2003 4:44 pm

Post by Gilimi »

I am sorry about that. I am a newbie and didn't notice till after I posted. I will try to be more aware next time.

Joe
Post Reply