PHP-MySQL-Class icon indicating copy to clipboard operation
PHP-MySQL-Class copied to clipboard

Stops working

Open xvilo opened this issue 10 years ago • 4 comments

Hello,

I'm using this wonderfull class in a IRC logbot made in PHP ofcourse ;) with SmartIRC.... But after 115-125 queries it stops working, well, i don't get the usual 1 as return, no error's or such....

As soon as i click on empty truncate function in PHPmyAdmin, restart the bot it works like a charm again.... Is this a bug in the script it self, am i doing something wrong or is it something with the Db?

Code to add something:

function logtext(&$irc, &$data){

            $oMySQL = new MySQL('phpircbot', 'USER', 'PASSWORD', 'HOST');

            $message    = $data->message;
            $channel    = $data->channel;
            $nick       = $data->nick;
            $ident      = $data->ident;
            $host       = $data->host;
            $from       = $data->from;
            $type       = $data->type;
            $date       = date( 'j-n-Y' );
            $time       = date( 'G:i:s' );


            $newLog = array('nick' => $nick,  
              'ident' => $ident,  
              'host' => $host,  
              'type' => $type,  
              'from' => $from,  
              'channel' => $channel,  
              'message' => $message, 
              'time' => $time  
               );

            print_r($newLog);

            $oMySQL->Insert('irclog', $newLog);

            echo $lastError;

        }

when something needs to be logged the function will start, first it creates a new connection, get's all the data then creates the array, prints the array into the console (debug) and sends it into the class to de DB.....

Or should i just start once the new mysql connection as soon as the bot's starts?

Thanks in advance,

//sem

EDIT: Truncate whole table while bot is running also fixes the problem, so i guess it's a DB problem,.. But still the question tho ;)

xvilo avatar Apr 22 '14 19:04 xvilo

The Code looks ok and if it work well the first 100 times i don't see a reason why it shouldn't do it the next 100 times. do you have to truncate the whole table? AI restart at 1 and all data get lost? o.O

Gummibeer avatar Apr 22 '14 22:04 Gummibeer

Do you close the open connections? I don't see in your script the call to the close method, that could be your problem.

argosback avatar Apr 28 '14 17:04 argosback

Well, the problem had been solved, i had the wrong properties(??) for the ID field... When i tried to add something in PHPMyAdmin i had an error... But still, maybe a bug, the script wasn't returning anything....

xvilo avatar Apr 28 '14 18:04 xvilo

There are forbidden keywords and you use at least two of them (from and time) as column names please refer to the last full list http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

cfilippe avatar Oct 27 '14 22:10 cfilippe