SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: DELETE problems

  1. #1
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DELETE problems

    Please help me. I'm straining my brain for problably a simple solution. Any way I want to delete a row from a table named tbl_order_item. My query is
    PHP Code:
    DELETE FROM tbl_order_item WHERE od_id $orderId
    And order id I know is fine. My problem is that its not deleting the row when I tell it to.
    the column names in order are;
    od_id, pd_id, od_qty, user_id
    Thanks

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed the delete a little bit and now it still doesn't work.
    And yes there is info in this new variable too. Basically I want to delete all rows that match the $user and the $orderId;
    PHP Code:
    DELETE FROM tbl_order_item WHERE od_id $orderId AND user_id $user 

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    is it deleting anything?

    please show the create table for tbl_order_item

    please edit you php code to echo the completed query as an HTML comment and use the view source function of your broswer to confirm that you are building the query you think you are.

  4. #4
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No thats the problem its not deleting anything.
    CREATE TABLE `tbl_order_item` (
    `od_id` int(10) unsigned NOT NULL default '0',
    `pd_id` int(10) unsigned NOT NULL default '0',
    `od_qty` int(10) unsigned NOT NULL default '0',
    `user_id` varchar(55) collate latin1_general_ci NOT NULL default '',
    PRIMARY KEY (`od_id`,`pd_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

  5. #5
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm such an idiot I forgot the $result line that actually runs the query. Anyway now its giving me this error
    Query failed. Unknown column 'bill8' in 'where clause'

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ~#@$!#@~$#@!$!@$!@

    if you were getting an error, why didn't you post it!?

  7. #7
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wasn't getting the error at that time. Sorry I fixed it now. I guess next time I will look over my querys a little better. Thanks for replying longneck

  8. #8
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cmuench
    Query failed. Unknown column 'bill8' in 'where clause'
    and that is why i suggested you echo the complete query to an HTML comment. you would have noticed (maybe) that you have no quotes are the user name in your query.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •