Help with this code

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
kirk93
Forum Newbie
Posts: 5
Joined: Sun Mar 21, 2010 8:32 am

Help with this code

Post 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
User avatar
KrypticNinja
Forum Newbie
Posts: 16
Joined: Thu Mar 18, 2010 6:14 pm

Re: Help with this code

Post 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.
kirk93
Forum Newbie
Posts: 5
Joined: Sun Mar 21, 2010 8:32 am

Re: Help with this code

Post by kirk93 »

<?php $month = date("F"); include("calender/".$month.".txt"); ?>

changed to that and still no hope

i dont know what else to try
User avatar
KrypticNinja
Forum Newbie
Posts: 16
Joined: Thu Mar 18, 2010 6:14 pm

Re: Help with this code

Post by KrypticNinja »

it may help if you post the code, seeing it all together may help to find the problem.
kirk93
Forum Newbie
Posts: 5
Joined: Sun Mar 21, 2010 8:32 am

Re: Help with this code

Post by kirk93 »

that is it its at the top of the last reply
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Help with this code

Post 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"?
kirk93
Forum Newbie
Posts: 5
Joined: Sun Mar 21, 2010 8:32 am

Re: Help with this code

Post by kirk93 »

hi sorry it workes now the file was called march.txt not March.txt

thanks for your help
Post Reply