...

View Full Version : Not deleting from the database



The_Return
08-25-2009, 12:52 AM
It displays everything at the echo but its not deleting it nor does it give a error

the database looks like this:

http://screensnapr.com/u/7w4fh8.png

http://screensnapr.com/u/kg8pf1.png

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



<?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


?>

mlseim
08-25-2009, 01:39 AM
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.

The_Return
08-25-2009, 01:43 AM
No the picture was a picture of the table from my database the part that does the deleting is



$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?

whizard
08-25-2009, 03:15 AM
$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

The_Return
08-25-2009, 03:32 AM
ok now it says MySQL server has gone away and by aim parts I mean



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum