Simple MySQL query not working!

Discussion in 'PHP' started by MyFlash13, Jun 23, 2008.

  1. #1
    Why doesn't this simple peice of SQL work?

    DELETE FROM websites
    WHERE alias = 'mycoolsite'; user = 'admin'
    PHP:
    I simply want to delete the row which contains the alias 'mycoolsite' and the user 'admin'.

    Yet it keeps giving me this error:
    Warning: mysql_query() [http://www.mysql.com/doc]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; user = 'admin'' at line 2 in \deletesite.php on line 31
    Code (markup):
     
    MyFlash13, Jun 23, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    DELETE FROM websites
    WHERE `alias` = 'mycoolsite'
    AND `user` = 'admin';
     
    Danltn, Jun 23, 2008 IP
  3. MakeThatDollar

    MakeThatDollar Notable Member

    Messages:
    4,451
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    225
    #3
    Yeah just as Danltn said. Remove the ; and replace it with AND.. and use ' around the table values.
     
    MakeThatDollar, Jun 23, 2008 IP
  4. MyFlash13

    MyFlash13 Peon

    Messages:
    137
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks a lot everyone! It worked!
     
    MyFlash13, Jun 24, 2008 IP