Back Reply to topic
Goto page Previous  1, 2, 3
kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * *
Posted: Post 02:47 Wed - Jul 02, 2008

Per your instructions. and a little modification based off what you showed me.

I changed
Code:

$db->exec('DELETE * FROM '.$dbconfig['dbprefix'].'online_toons;');
say("Deleted old online list",1);


to this
Code:

$sql2 = 'DELETE * FROM '.$dbconfig['dbprefix'].'online_toons;';
$stmt2 = $db->prepare($sql2);
     if(false === $stmt2->execute())   
      say ("There has been a problem executing the SQL: ".print_r($stmt2->errorInfo(), true));
     else 
      say ("Deleted old online list",1);


and I found that DELETE *
is not valid for this.

so I looked around in some of the code you had written and found the command TRUNCATE . This worked like a charm

Code:

$sql2 = 'TRUNCATE TABLE '.$dbconfig['dbprefix'].'online_toons;';
$stmt2 = $db->prepare($sql2);
     if(false === $stmt2->execute())   
      say ("There has been a problem executing the SQL: ".print_r($stmt2->errorInfo(), true));
     else 
      say ("Deleted old online list",1);




and for anyone wanting the whole code.
Code:

<?php

   global $BuddyList,$guildmates,$guildmains,$db,$dbconfig,$buddyTimer;
   if (!isset($buddyTimer) || time()-$buddyTimer>330)
   {
      $buddyTimer = time();
   
//      $db->exec('DELETE * FROM '.$dbconfig['dbprefix'].'online_toons;');
     $sql2 = 'TRUNCATE TABLE '.$dbconfig['dbprefix'].'online_toons;';
      $stmt2 = $db->prepare($sql2);
//      say("Deleted old online list",1);
      if(false === $stmt2->execute())   
            say ("There has been a problem executing the SQL: ".print_r($stmt2->errorInfo(), true));
      else 
            say ("Deleted old online list",1);
     
      $BuddyClasses=array(); foreach($BuddyList as $buddy) $BuddyClasses[]=$buddy["class"];
      $BuddySorted =$BuddyList;
      array_multisort($BuddyClasses,SORT_ASC,$BuddySorted);
      $BuddyClasses="";
   
      $toon_name = '';
      $class = '';
      $level = '';
      $sql = 'INSERT INTO '.$dbconfig['dbprefix'].'online_toons VALUES (:toon_name, :class, :level);';
      $stmt = $db->prepare($sql);
      $stmt->bindParam(':toon_name', $toon_name);
      $stmt->bindParam(':class', $class);
      $stmt->bindParam(':level', $level);

      foreach ($BuddySorted as $buddy)
      {
         if ( $guildmates[$buddy["name"]] && $buddy["status"]>0 )
         {
            $toon_name = $buddy["name"];
            $class = $buddy["class"];
            $level = $buddy["level"];
      if(false === $stmt->execute())
            say ("There has been a problem executing the SQL: ".print_r($stmt->errorInfo(), true));
      else
            say ("Added ".$buddy["name"]." ".$buddy["class"]." ".$buddy["level"]." ");
         }
      }
   }

?>
Reply with quote


kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * *
Posted: Post 03:15 Thu - Jul 03, 2008

Last remaining piece to this issue I've found with Vrykolas' help

My setup uses Vrykolas sql query addition.

Then I use it to connect to a MySQL database on my webserver hosted by hostmonster.


Hostmonster appears to have a 60second timeout on all database queries.
So I had to change one of the the queries to query the database every 50seconds to keep the connection alive.
Reply with quote


Guest 
 
Topics: 6
 
 
 
Posted: Post 07:30 Sat - Jul 05, 2008

kardson wrote:


Hostmonster appears to have a 60second timeout on all database queries.
So I had to change one of the the queries to query the database every 50seconds to keep the connection alive.


May i ask what query you altered to keep the connection alive? i am running into the same issue at the moment.
Reply with quote


Vrykolas 
Blue-Ribbon Chicken 
Topics: 0
Posts: 10
Playing:  Age of Conan
Ingame:  Vrykolas
Years registered: * * * * * * * * * * *
Posted: Post 11:44 Sat - Jul 05, 2008

Copied from our discussions:

Quote:
Another thing to try would be to increase the frequency of a database operation (reduce the timer on your code from 300 to 60 or even 10...) as a way of keeping the connection alive...

Code:

if (!isset($buddyTimer) || time()-$buddyTimer>330)

becomes
Code:

if (!isset($buddyTimer) || time()-$buddyTimer>60)

Reply with quote


Goto page Previous  1, 2, 3
Back Reply to topic