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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts

    Not deleting from the database

    It displays everything at the echo but its not deleting it nor does it give a error

    the database looks like this:





    The echo matches the same in the database....so I'm clueless whys not removing.

    PHP Code:
    <?php
    ob_implicit_flush
    (true); 
    include(
    "aimclassw.php"); //Toc
     
    //database connect

    $query3 "SELECT COUNT(*) as num FROM jobs WHERE status = '0'";
    $total_jobs mysql_fetch_array(mysql_query($query3));
    $total_jobs $total_jobs[num];

    if (
    $total_jobs 0) {
    $b = new Aim("screenname","password",4); 
    $b->registerHandler("Config","onConfig"); 
    $b->registerHandler("Nick","onNick"); 
    $b->signon();
    sleep(3); // delay after sign in 
    }

    if (
    $total_jobs 0) {
    while(!
    defined("CAN_SEND")){ 
    $b->receive(); 
    }
    }
    //end if

    function onConfig() 

    define("CAN_SEND",1); 
    return; 


    if (
    $total_jobs 0) {

    $query "SELECT * FROM jobs WHERE status = '0'";
    $result mysql_query($query) or die(mysql_error());

    while(
    $row mysql_fetch_array($result)) {

    $message $row['message'];
    $hostid $row['hostid'];

    //select all the aims with the host id given
    $q "SELECT aim FROM friends WHERE hostid = '$hostid'";
    $re mysql_query($q) or die(mysql_error());

    while(
    $r mysql_fetch_array($re)){

    $aim $r['aim'];

    $b->sendIM("$aim","$message"); 
    sleep(3); 

    }
    //End while loop

    $query2 "DELETE FROM jobs WHERE message = '$message' AND hostid = '$hostid'";
    $result2 = @mysql_query($query2); 
    echo 
    "It should have deleted this message $message and this hostid $hostid";

        } 
    //end loop 
    }//End if 


    ?>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Do you delete it by clicking on the red X?
    If so, tell us how that works... what is the URL (link) for the X?

    I'm not seeing how it knows which one to delete.

  • #3
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts
    No the picture was a picture of the table from my database the part that does the deleting is

    PHP Code:
    $query2 "DELETE FROM jobs WHERE message = '$message' AND hostid = '$hostid'";
    $result2 = @mysql_query($query2); 
    so it matches the exact message and hostid to delete it.

    Update: If you comment out the aim parts it deletes it fine its weird is their anyway other way to delete it?
    Last edited by The_Return; 08-25-2009 at 03:04 AM.

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    $result2 = @mysql_query($query2);

    Remove the @ (which supresses errors) and add or die(mysql_error()), which shows them.

    (End with: $result2 = mysql_query($query2) or die(mysql_error());

    That way, when you run it, it will tell you any errors.

    Also, what do you mean by "aim parts" of the query?

    Dan
    Last edited by whizard; 08-25-2009 at 03:15 AM. Reason: iCode
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts
    ok now it says MySQL server has gone away and by aim parts I mean

    PHP Code:
    if ($total_jobs 0) {
    while(!
    defined("CAN_SEND")){ 
    $b->receive(); 
    }
    }
    //end if

    function onConfig() 

    define("CAN_SEND",1); 
    return; 
    }  

    $b->sendIM("$aim","$message"); 
    it also doesn't display this anymore It should have deleted this message test 2 and this hostid c9723097991b56826b1b854f61c177f3
    Last edited by The_Return; 08-25-2009 at 03:34 AM.


  •  

    Posting Permissions

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