我在计算表格内容并将值保存在文件中。当有一个插入到这个表中时,将创建另一个文件,并保存新的计数编号。现在我想获得这个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 –
我强烈建议使用数据库来存储数据。 –