Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2008, 12:39 PM   PM User | #1
docock
Regular Coder

 
Join Date: Feb 2007
Posts: 192
Thanks: 18
Thanked 1 Time in 1 Post
docock is an unknown quantity at this point
compare day and last run

In the code below, I retrieve the current day and read out a text file which contains the last day the code ran. If the current day and the day in the text file are different from each other the the variable $nieuw should get the value 1, otherwise the value 0.

But somehow, this doesn't work. When I try the coding the variable $nieuw returns 1 every time. Whats wrong with my coding?


$michael=Date("d");

$handle = fopen("filed.txt","r+"); //mind the + this means to write AND read
$read = fread($handle,filesize("filed.txt"));
if ($read<>$michael){fwrite($handle,$michael);$nieuw="1";}else{$nieuw="0";}
fclose($handle);

echo $nieuw;
docock is offline   Reply With Quote
Old 12-18-2008, 01:37 PM   PM User | #2
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
try echo'ing out the 2 dates being compared too, maybe there is some screwy formatting you're not seeing causing them to be inequal
ohgod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:18 PM.


Advertisement
Log in to turn off these ads.