Page 1 of 1
Help with this code
Posted: Sun Mar 21, 2010 8:39 am
by kirk93
Hi i have been studying php,html,css and java for about 4 years now and there is one code that i have played around with done what i think i can do but it still does not work.
//here is the code that has something wrong with it
<?php $month = date("F");
include("calender/$month.txt"); ?>
/ end of code
I have proberly misses somthing but please help
Re: Help with this code
Posted: Sun Mar 21, 2010 9:16 am
by KrypticNinja
I'm guessing it keeps looking for a file called $month.txt, instead of the actual month.
you could call the include like this:
include("calendar/". $month . ".text");
I've had a lot of simmilar problems myself. Apparently it has something to do with the way PHP interprets strings with double quotes. I've also seen people use curly brackets {} around variables in strings, that seems to help as well.
Hope that helps.
Re: Help with this code
Posted: Sun Mar 21, 2010 9:52 am
by kirk93
<?php $month = date("F"); include("calender/".$month.".txt"); ?>
changed to that and still no hope
i dont know what else to try
Re: Help with this code
Posted: Sun Mar 21, 2010 10:28 am
by KrypticNinja
it may help if you post the code, seeing it all together may help to find the problem.
Re: Help with this code
Posted: Sun Mar 21, 2010 10:34 am
by kirk93
that is it its at the top of the last reply
Re: Help with this code
Posted: Sun Mar 21, 2010 12:14 pm
by flying_circus
Code: Select all
<?php
$month = date("F");
include_once("calender/".$month.".txt"); // Includes "calender/March.txt"
?>
This will include a file "calender/March.txt".
What error message are you getting? How does it "not work"?
Re: Help with this code
Posted: Sun Mar 21, 2010 1:23 pm
by kirk93
hi sorry it workes now the file was called march.txt not March.txt
thanks for your help