SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL Row deletion...PROBLEM!

    I am having some problems with my script:

    Code:
    $id = $HTTP_GET_VARS['id'];
    
    require("config.php");
    
    $connect = mysql_connect($server, $username, $password);
    if(!$connect)
    {
            die("There is a MySQL error,<br>MySQL Returned: \n".mysql_error());
    }
    
    mysql_select_db($database);
    
    mysql_query("DELETE FROM 'ragesc_clients' WHERE 'ID' = '".$id."'");
    
    mysql_close($connect);
    
    header("location: index.php");
    It wont delete the row that i indicate.... any ideas whats wrong?

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is anybody online?

  3. #3
    If it aint Dutch it aint much Kilroy's Avatar
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using $_GET['id'] instead of $HTTP_GET_VARS['id']

    Also, this is not really relevant to your problem, but make sure the page you are on is a protected page, because everyone could specify the ID in the URL to delete rows from your database.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i verified that before by doing this:

    Code:
     $id = $HTTP_GET_VARS['id'];
    
    echo $id;
    
    require("config.php");
    I cant see any problems with it, and it returns no errors, i just returns back to index.php when done, but it hasnt deleted the row...

  5. #5
    If it aint Dutch it aint much Kilroy's Avatar
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What PHP version are you using? Because you should be using $_GET regardless..

    Anyway, if you're saying that echo $id throws up the ID you want to delete the row from, it will be something else in your code. Can you perhaps post your config.php file? Change the values for your username and password, I only need to take a look at its structure.

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YAY!!!

    I whent into my hosts controll panel and found "phpMyAdmin". I simulated a deletion and it returned:

    Code:
    DELETE FROM `ragesc_clients` WHERE `ID` = '1' LIMIT 1;
    DELETE FROM `ragesc_clients` WHERE `ID` = '4' LIMIT 1;
    It turns out that the ";" at the end of the line is required, i never knew that , thanx for your help anyways, and i most definately will implement some security onto that page

  7. #7
    If it aint Dutch it aint much Kilroy's Avatar
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The ; is only needed when you have multiple DELETE statements, so that MySQL knows where the next task starts.

    Good luck with your project

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    UK
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good luck with your website, looks quite complex too me, though it is still unfinished because i cant download your project yet i will bookmark that for later...

  9. #9
    If it aint Dutch it aint much Kilroy's Avatar
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's coming along nicely... expect a beta around New Year

    Thanks,

    Kilroy

  10. #10
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Compare your first snippet

    DELETE FROM 'ragesc_clients' WHERE 'ID' = '".$id."'");

    with the second

    DELETE FROM `ragesc_clients` WHERE `ID` = '1'

    Feel the difference...


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
  •