elexion Posted November 6, 2009 Share Posted November 6, 2009 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 More sharing options...
justsomeguy Posted November 6, 2009 Share Posted November 6, 2009 Why can't you tell if it's working? You should be able to look at the HTML source and see what it included. Link to comment Share on other sites More sharing options...
Redroest Posted November 7, 2009 Share Posted November 7, 2009 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 More sharing options...
requnix Posted November 7, 2009 Share Posted November 7, 2009 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 More sharing options...
Redroest Posted November 7, 2009 Share Posted November 7, 2009 Whaha Link to comment Share on other sites More sharing options...
Ingolme Posted November 7, 2009 Share Posted November 7, 2009 Are you making use of the $date_switcher parameter at all? function date_switcher($date_switcher) You might as well omit it if it's not being used anywhere. Link to comment Share on other sites More sharing options...
elexion Posted November 9, 2009 Author Share Posted November 9, 2009 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.Whahaheh glad i made someone laugh atleast :)Thanks for the reply's everyone Link to comment Share on other sites More sharing options...
elexion Posted November 9, 2009 Author Share Posted November 9, 2009 alright i just managed to fix it thanks for the help everyone Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.