Page 1 of 1

incrementing a number

Posted: Tue May 22, 2007 12:00 am
by ChessclubFriend
if I have a file with the number 1 in it, and i want to increase the number to 2, this is how I tried to do it.

Code: Select all

$IDcount = fread($voteIDcount,filesize($voteIDcount));
$IDcount = $IDcount + 1;

Posted: Tue May 22, 2007 12:08 am
by volka
You script isn't running with error_reporting=E_ALL and display_errors=on. Otherwise you would have get error/notice messages.
Do you know how to adjust error_reporting and display_errors?

fread() takes a filehandle as first parameter, filesize() a string containing the filename. You've passed $voteIDcount to both functions but it can't be both, a filehandle and a string.

Posted: Tue May 22, 2007 3:37 am
by stereofrog
file_get_contents is much better than fread() + filesize()