Description:
We have developed an application using php, C++ and mysql. Our application has to be run 24 hours at a stretch. It is a very simple code, however, the sql table crashes quite often. The database contains 3 tables, out of which one only fails. The type of that table is MyISAM.
The error which I get is as follows:
"Table is marked as crashed and should be repaired."
The code is as follows:
<?php
include("dbconn.php");
$temp=array();
$temp[1]="";
$result= mysql_query("select * from temporary_tag_collection where upload_status=0 order by timestamp");
while($row=mysql_fetch_array($result))
{
$temp_date=explode(" ",$row['timestamp']);
$query1=mysql_query("select count(*) as cnt from attendance where tag_id='".$row['tag_id']."' and `date`='".$temp_date[0]."' and status='y' and in_out_status=0");
$count = mysql_fetch_assoc($query1);
if($count["cnt"]!=0)
{
/*Update the time_out data*/
mysql_query("update attendance set time_out='".$row['timestamp']."',in_out_status=1 where tag_id='".$row['tag_id']."' and in_out_status=0") or die(mysql_error());
/*Change the URL */
$url_n='http://abc.php?smartcard_id='.$row['tag_id']."&time_in=".urlencode($row['timestamp'])."&ip_address=".urlencode($_SERVER['REMOTE_ADDR'])."&in_out_status=1";
$temp = file($url_n);
echo $temp[1];
if($temp[1]!="")
mysql_query("update temporary_tag_collection set upload_status=1 where tag_id='".$row['tag_id']."'") or die(mysql_error());
}
else if($count['cnt']==0)
{
$set_in_out_status=0; //
mysql_query("insert into attendance(tag_id,time_in,`date`,in_out_status) values('".$row['tag_id']."','".$row['timestamp']."','".$temp_date[0]."','".$set_in_out_status."')") or die(mysql_error());
$url_n='http://abc.php?smartcard_id='.$row['tag_id']."&time_in=".urlencode($row['timestamp'])."&ip_address=".urlencode($_SERVER['REMOTE_ADDR'])."&in_out_status=".$set_in_out_status;
$temp = file($url_n);
echo $temp[1];
if($temp[1]!="")
mysql_query("update temporary_tag_collection set upload_status=1 where tag_id='".$row['tag_id']."'") or die(mysql_error());
}
}
?>
Please help us in this regard.
How to repeat:
It is repeated after our system runs for more than 2-3 days at a stretch.