incrementing a number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ChessclubFriend
Forum Newbie
Posts: 21
Joined: Sun Mar 25, 2007 9:13 pm

incrementing a number

Post 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;
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

file_get_contents is much better than fread() + filesize()
Post Reply