我在計算表格內容並將值保存在文件中。當有一個插入到這個表中時,將創建另一個文件,並保存新的計數編號。現在我想獲得這個2值並進行比較。我總是得到一個強有力的結果。
這是我的代碼:?獲取內容文件並將其轉換爲int php
$crc1 = strtoupper(dechex(crc32(file_get_contents('lastinsert.txt'))));
$crc2 = strtoupper(dechex(crc32(file_get_contents('newinsert.txt'))));
if($crc1>$crc2){
echo $diff=abs(intval($crc1)-intval($crc2));
}
$querycount="SELECT count(*) from relations";
if (filesize('lastinsert.txt') == 0){
echo "The file is DEFINITELY empty";
}
else if($crc1!=$crc2){ //if the lastinsert is different from the new one we create the newinsert file
echo "The file isn't empty";
if($query_run= mysql_query($querycount)){
while($query_row = mysql_fetch_assoc($query_run)) {
$res=print_r($query_row);
file_put_contents("newinsert.txt",$query_row);
}
}
}
if($query_run= mysql_query($querycount)){
while($query_row = mysql_fetch_row($query_run)) {
$res=print_r($query_row);
file_put_contents("lastinsert.txt",$query_row);
}
}
你的奇怪結果是什麼? –
這是結果之一2470247或結果必須是2 –
我強烈建議使用數據庫來存儲數據。 –