Sometimes due to more traffic mysql got hang, when i check it thereare to many tables running, open and locked, to slove this issue i want to try this code <?php $con = mysql_connect( "localhost", "user", "pass" ) or die( "can not connect" ); if( $con ) echo "Connected<br>"; $result = mysql_query( "SHOW FULL PROCESSLIST", $con ); while( $row = mysql_fetch_array( $result, $con ) ) { $process_id = $row["id"]; if ($row["Time"] > 100 ) { $sql = "KILL $process_id"; $res = mysql_query( "$sql", $con ); if( $res ) { echo "Mysql Process ID $process_id has been killed<br>"; } } else echo "Row not found?<br>"; } ?> Code (markup): I tried this code for cron job to kill slow query but when i run this cron.php then i got this error Connected Warning: mysql_fetch_array() expects parameter 2 to be long, resource given in /home/r/public_html/da/cron.php on line 7 Help me I have SMF 2.0.4 default theme
Means the query is failing. Try replacing: $result = mysql_query( "SHOW FULL PROCESSLIST", $con ); with: if(!$result = mysql_query( "SHOW FULL PROCESSLIST", $con )) { die(mysql_error()); } May just be a permission problem.
Connected Warning: mysql_fetch_array() expects parameter 2 to be long, resource given in /home/r/public_html/da/cron.php on line 9 Still same error