Jump to content

Need Help On A Simple Function


elexion
 Share

Recommended Posts

hey guys, It's been a while since i;ve been working with PHP but now i'm trying to write a simplefunction for a website. I have included the function.php file into the index page so no problems there.It just wont show if the function is actually working or not.this is my code i hope someone can help me out or send me off in the right direction:<?phpfunction date_switcher($date_switcher){$switch = date("Y/m");if ($switch==("2009/11")) { echo("succes"); include("style_succes.css"); ?> <link rel="stylesheet" href="style_standard.css" type="text/css"> <?php }else { include("style_standard.css"); }}?>as you see i'm trying to make the function look at the date that's on the computer and based on thatto pick a stylesheet.thanks for the help in advance i appreciate it.

Link to comment
Share on other sites

To make things easier for all of us:-please put the scripts between code tags-Give an example on how you call the function-Use texthintsI can't really tell what is wrong but, it would be easier if you format the script with tabs etc. This will allow you to scan your script much faster and when an error occurs it can also be spotted much faster:Below is the formatted code. As you see its better to scan and it will save time on bigger scripts

<?phpfunction date_switcher($date_switcher){  $switch = date("Y/m");  //If the date is 2009 month 11  if ($switch==("2009/11"))  {	echo("succes");	include("style_succes.css");	//I made php to echo the stylesheet code because it is easier to read without those ?> <?php tags. It now looks like it belongs within the if-statement	echo "<link rel='stylesheet" href='style_standard.css' type='text/css'>";  }  else  {	include("style_standard.css");  }}?>

Link to comment
Share on other sites

	echo "<link rel='stylesheet" href='style_standard.css' type='text/css'>";

Ah, a fatal quotation error...It should be like this:
	echo "<link rel='stylesheet' href='style_standard.css' type='text/css'>";

:)

Link to comment
Share on other sites

Why can't you tell if it's working? You should be able to look at the HTML source and see what it included.
Well the testing page doesnt have a background color but the two different style sheets i'm trying to include do, And yes you'reright and i did check that after reading your tip and noticed the function.php file is indeed included in the page however still not working but thanks for pointing that one out
To make things easier for all of us:-please put the scripts between code tags-Give an example on how you call the function-Use texthintsI can't really tell what is wrong but, it would be easier if you format the script with tabs etc. This will allow you to scan your script much faster and when an error occurs it can also be spotted much faster:
Sorry about the lack of texthints i figured the code being so small it wouldnt be a big problem figuring out. As for calling the function like i said i'm just picking up PHP again and therefor the test page only has the function included into it.
Whaha
heh glad i made someone laugh atleast :)Thanks for the reply's everyone
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...