Here's the example:
You have a world writable file called lastquote.cfg on your server with a
one or two digit number in it. When you run the script below, it reads the
value, increments the value by one and then rewrites it into the file.
<?php
$fp = fopen("lastquot e.cfg", "r");
$data = fread($fp, 10);
fclose($fp);
echo "Last quote: ".$data."<b r>";
$qid = $data + 1;
$fp = fopen("lastquot e.cfg", "w");
echo "<br>".$qid ;
fwrite($fp, $qid);
fclose($fp);
?>
Sounds simple, right? My problem is that one one computer, this does
exactly as it should. It increments the value and writes the file. But on
my production server, the number will magically be incremented by two,
sometimes by one and I can't find an explanation. The strange thing is
that if I have it echo what it's going to write into the file, it echos the
correct value. But when it writes it, it's incorrect! Any idea what the
hell is going on?
You have a world writable file called lastquote.cfg on your server with a
one or two digit number in it. When you run the script below, it reads the
value, increments the value by one and then rewrites it into the file.
<?php
$fp = fopen("lastquot e.cfg", "r");
$data = fread($fp, 10);
fclose($fp);
echo "Last quote: ".$data."<b r>";
$qid = $data + 1;
$fp = fopen("lastquot e.cfg", "w");
echo "<br>".$qid ;
fwrite($fp, $qid);
fclose($fp);
?>
Sounds simple, right? My problem is that one one computer, this does
exactly as it should. It increments the value and writes the file. But on
my production server, the number will magically be incremented by two,
sometimes by one and I can't find an explanation. The strange thing is
that if I have it echo what it's going to write into the file, it echos the
correct value. But when it writes it, it's incorrect! Any idea what the
hell is going on?
Comment