View Single Post
  #3 (permalink)  
Old October 11th, 2003, 08:09 PM
richard.york's Avatar
richard.york richard.york is offline
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts

Here's an easy way to find out if you have write permission on that directory:

if (!fwrite($fp, $contatore))
     echo "Error: unable to write to file!";

But PHP would probably issue an error or warning if the write was unsuccessful anyway.

In PHP many functions return false if they are unsuccessful in whatever operation is being performed, this is very handy knowledge when you consider adding error reporting to your code.

So far from my research everything looks fine. Other that the typecast used may cause a value other than the expected.

Easy way to find that out:

$contatore = (int) fread ($fp, 20);

echo $contatore." (typecasted)<br />\n";

$contatore = fread ($fp, 20);

echo $contatore." (non-typecasted)<br />\n";

This will give you an answer to that question, provided that the value retrieved from cacchio.dat is a value other than null or zero. Typecasting is completely optional in PHP, the only true benefit from it (IMHO) is getting used to the idea for the sake of learning other languages that do require it.

My *hunch* on this is that the variable's value is being set to zero regardless of the function's result. I bring this up because I ran into a very difficult to find bug in an application I was designing because I had typecast a function's result.

Please let us know if you get it solved!

: )

Smiling Souls