Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    UK
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    delete query does not work in php script (resolved)

    I am trying to delete rows from a database if a column of that row's date is 2 days old.

    I echo out the variable and run it through PHPMyAdmin and it works, however, through the php script nothing happens, no errors, all it does it displays the variable.

    Anyone any ideas?

    PHP Code:
    <?php

    include("includes/conn.php");

    $today date("d/m/Y"strtotime("-2 day"));
    $del "DELETE FROM users WHERE signup_date = '$today'";
    echo 
    $del;
    $query mysql_query("DELETE FROM users WHERE signup_date = '$today'") or die(mysql_error());
    if (
    mysql_affected_rows() > 0) {
        echo (
    mysql_affected_rows);
    }

    ?>
    Thanks in advance
    Last edited by bfsog; 09-21-2005 at 12:53 AM. Reason: fixed, feel free to delete

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    $query mysql_query("DELETE FROM users WHERE signup_date = '$today'") or die(mysql_error());
    if (
    mysql_affected_rows($query) > 0) {
        echo 
    mysql_affected_rows($query);

    You need to give the mysql_effected_rows a variable/query to run itself against, which you hadn't done


  •  

    Posting Permissions

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