6 Replies - 1050 Views - Last Post: 27 August 2009 - 04:10 PM Rate Topic: -----

#1 pspfreak101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 28-July 07

Won't delete from database

Posted 24 August 2009 - 07:15 PM

I'm am one step away from this being complete all it needs to do it delete the job after its finished but due to the aim toc its not letting it delete. Is their work around or statement I could do to successfully preform the deletion.

the database looks like this:

Posted Image -- jobs database

Posted Image -- This is the output



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


?>


This post has been edited by pspfreak101: 24 August 2009 - 07:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Won't delete from database

#2 peter yianni   User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 310
  • Joined: 04-June 09

Re: Won't delete from database

Posted 24 August 2009 - 07:33 PM

View Postpspfreak101, on 24 Aug, 2009 - 06:15 PM, said:

I'm am one step away from this being complete all it needs to do it delete the job after its finished but due to the aim toc its not letting it delete. Is their work around or statement I could do to successfully preform the deletion.

the database looks like this:

Posted Image -- jobs database

Posted Image -- This is the output



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


?>



TRY THIS

"DELETE FROM jobs Where `message`=$message";
Was This Post Helpful? 0
  • +
  • -

#3 pspfreak101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 28-July 07

Re: Won't delete from database

Posted 24 August 2009 - 07:38 PM

Nope but when I add or die(mysql_error()); I get this MySQL server has gone away

This post has been edited by pspfreak101: 24 August 2009 - 07:39 PM

Was This Post Helpful? 0
  • +
  • -

#4 peter yianni   User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 310
  • Joined: 04-June 09

Re: Won't delete from database

Posted 24 August 2009 - 07:46 PM

View Postpspfreak101, on 24 Aug, 2009 - 06:38 PM, said:

Nope but when I add or die(mysql_error()); I get this MySQL server has gone away


go and try from mysql and see if u can delete from there it will give u the code to use if u can get it working
Was This Post Helpful? 0
  • +
  • -

#5 smacdav   User is offline

  • D.I.C Head

Reputation: 56
  • View blog
  • Posts: 177
  • Joined: 06-June 09

Re: Won't delete from database

Posted 24 August 2009 - 07:52 PM

View Postpspfreak101, on 24 Aug, 2009 - 08:38 PM, said:

Nope but when I add or die(mysql_error()); I get this MySQL server has gone away


There is a page in the MySQL manual about the causes of this error: http://dev.mysql.com.../gone-away.html

I would recommend going through the list of possible causes and seeing if any of them are the reason in this case.
Was This Post Helpful? 0
  • +
  • -

#6 pspfreak101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 28-July 07

Re: Won't delete from database

Posted 24 August 2009 - 07:53 PM

Well it seems that statement is fine its just that mysql is disconnecting because its sending out notifications and causing the mysql to disconnect so by the time it gets to the delete command it can't because its not connected. Is their anyway to reconnect when its done sending aim messages?
Was This Post Helpful? 0
  • +
  • -

#7 exally   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-August 09

Re: Won't delete from database

Posted 27 August 2009 - 04:10 PM

try using mysql_unbuffered_query instead of mysql_query, it fixed a problem i had with large tables a while back that was causing the same problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1