Results 1 to 13 of 13

Thread: Cannot delete a row with PHP & MySQL

Hybrid View

  1. #1
    New Member
    Join Date
    Aug 2005
    Posts
    1

    Re: Cannot delete a row with PHP & MySQL

    I think you're forgetting there have to be quotes round the string in the query.
    So I think it's like this:

    Code:
    $result = mysql_query("DELETE FROM '" . $data[0] ."'  WHERE ID IN '" .$data[1] . "'");
    I added the single quotes... (if ID is a number in your database, you can delete the single quotes there)

    I hope it works, it's my first post here on the forum, and i just know the basics of PHP/MySQL, so don't shoot me if I'm wrong.

  2. #2

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Cannot delete a row with PHP & MySQL

    Quote Originally Posted by n0vembr


    did u try manually executing the statement in a query analyzer tool?
    Ran the same statement in PHP Admin and it worked fine.
    Quote Originally Posted by visualAd
    You need to use urly brackets to enclose arrays:
    { }
    Code:
    $result = mysql_query("DELETE FROM {$data[0]} WHERE ID IN({$data[1]})");
    What? I have several statements which alter rows and insert rows with arrays and they work fine without brackets. Why would delete require them? I'll try it just to double check but I don't understand that.
    Quote Originally Posted by visualAd
    Use echo() to output the query text an ensure it is what you expect. Then try n0vemberssuggestion of executing that exact text on the command line.
    Havn't had the chance of using echo or print. I'm going to give this a try later but it seems the issue is specifically with the sql query
    Quote Originally Posted by Geert
    I think you're forgetting there have to be quotes round the string in the query.
    Shouldn't matter and I've tried that anyway.

Posting Permissions

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



Click Here to Expand Forum to Full Width