Professional Web Applications Themes

Help with delete query please - MySQL

Hi Having problem with delete query. Below is query: $unconfirmedstatus = 'Unconfirmed'; $firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60 MINUTE AND status = $unconfirmedstatus"; $result = mysql_query($firstquery) or die ("Failed query of" . $firstquery . mysql_error()); Error message is as follows: Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2 MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause' Cant see where I'm going wrong. Unconfirmed is not the column - status is the column. Any help greatly appreciated. Donna...

  1. #1

    Default Help with delete query please

    Hi
    Having problem with delete query. Below is query:

    $unconfirmedstatus = 'Unconfirmed';
    $firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60 MINUTE
    AND status = $unconfirmedstatus";
    $result = mysql_query($firstquery) or die ("Failed query of" . $firstquery .
    mysql_error());

    Error message is as follows:

    Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2
    MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause'

    Cant see where I'm going wrong. Unconfirmed is not the column - status is the
    column.

    Any help greatly appreciated.
    Donna

    Donna Elles Guest

  2. #2

    Default Re: Help with delete query please

    Donna Elles wrote:
    > Hi
    > Having problem with delete query. Below is query:
    >
    > $unconfirmedstatus = 'Unconfirmed';
    > $firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL
    > 60 MINUTE AND status = $unconfirmedstatus";
    > $result = mysql_query($firstquery) or die ("Failed query of" .
    > $firstquery . mysql_error());
    >
    > Error message is as follows:
    >
    > Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() -
    > INTERVAL 2 MINUTE AND status = Unconfirmed Unknown column
    > 'Unconfirmed' in 'where clause'
    >
    > Cant see where I'm going wrong. Unconfirmed is not the column -
    > status is the column.
    >
    > Any help greatly appreciated.
    > Donna
    You missed the quotes to change Unconfirmed into a constant. Try:
    $firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60
    MINUTE
    AND status = '$unconfirmedstatus'";


    Paul Lautman Guest

  3. #3

    Default Re: Help with delete query please

    Donna Elles wrote:
    > Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2
    > MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause'
    Unconfirmed with no quotes around it is interpreted as a column name.
    'Unconfirmed' with quotes around it is interpreted as a string literal.

    Regards,
    Bill K.
    Bill Karwin Guest

  4. #4

    Default Re: Help with delete query please

    >$unconfirmedstatus = 'Unconfirmed';
    >$firstquery = "DELETE FROM Pendingsales WHERE time < NOW() - INTERVAL 60 MINUTE
    >AND status = $unconfirmedstatus";
    >$result = mysql_query($firstquery) or die ("Failed query of" . $firstquery .
    >mysql_error());
    >
    >Error message is as follows:
    >
    >Failed query of DELETE FROM Pendingtransactions WHERE time < NOW() - INTERVAL 2
    >MINUTE AND status = Unconfirmed Unknown column 'Unconfirmed' in 'where clause'
    >
    >Cant see where I'm going wrong. Unconfirmed is not the column - status is the
    >column.
    No, as written, Unconfirmed is a (nonexistent) column. Perhaps you meant:
    where status = 'Unconfirmed'

    Gordon L. Burditt
    Gordon Burditt Guest

Similar Threads

  1. advanced delete query sql
    By kabbi~thkek in forum Coldfusion Database Access
    Replies: 1
    Last Post: January 19th, 06:58 AM
  2. Delete form - Post data to a table and delete uponsubmit.
    By FusionRed in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: July 28th, 01:27 PM
  3. Delete row in query
    By jarilo in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: February 21st, 12:27 PM
  4. Delete key doesn't delete when datagrid is bound to a disconnected table
    By Fred Zolar in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: April 1st, 07:47 AM
  5. variable empty after after posting a delete query
    By Boefje in forum PHP Development
    Replies: 8
    Last Post: October 30th, 11:55 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139