Rawns Posted April 27, 2006 Share Posted April 27, 2006 Ive noticed that if I carry on making an indivdule page for each part of my site, Ill have to change the 'Latest News' bullets on each page! I cant be arsed with this so I have had the idea to make a simple PHP file which will print HTML out allowing me to only change the one file instead of every page.Im having issues though as im not that good with PHP. in my main page where I want the code headlines to be shown, Ive added this code: [code] <?phpinclude ("news.php");?>[/code]This should point to the news.php file if i'm right. In the news file, I've got this code:[code]<?php<?phpprint"Blog now online! <a href="#blog">full story...</a>";print"RSS News feed avaiable! <a href="#rss">full story...</a>";print"Guestbook & Forums go live! <a href="#forum">full story...</a>";print"Site Launch!<a href="#launch"> full story...</a>";?>[/code]Ive added it to my site and uploaded it all but nothing is displayed. Have I forgot something in the news.php file? Any help would be most appreciated! Quote Link to comment Share on other sites More sharing options...
Orio Posted April 27, 2006 Share Posted April 27, 2006 You ahve a problem because you havent escaped the quotes in the print. The server thinks that after <a href= the print is closed.This will work:<?phpprint"Blog now online! <a href=\"#blog\">full story...</a>";print"RSS News feed avaiable! <a href=\"#rss\">full story...</a>";print"Guestbook & Forums go live! <a href=\"#forum\">full story...</a>";print"Site Launch!<a href=\"#launch\"> full story...</a>";?>Orio. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 27, 2006 Share Posted April 27, 2006 The problem is becuase you are not escaping your quotes. As you are starting your print statement with a double quote ( " ) mark. PHp will stop the printing your text when it finds another occurance of a double quote.Now in order for PHP to not stop when it finds another double quote you will need to escape it, which means adding a forward slash infront of the quote like so: [b]\"[/b] however your last ending quote shouldn't be escaped though.So what I'm saying is this if you start of with a double quote, you should escape any doubles quotes within the string like so:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]print "Site Launch!<a href=[!--coloro:red--][span style=\"color:red\"][!--/coloro--][b]\"[/b][!--colorc--][/span][!--/colorc--]#launch[!--coloro:red--][span style=\"color:red\"][!--/coloro--][b]\"[/b][!--colorc--][/span][!--/colorc--]> full story...</a>";[/quote] Quote Link to comment Share on other sites More sharing options...
Rawns Posted April 27, 2006 Author Share Posted April 27, 2006 Thanks guys.Ive made the changes like you said but it still does not display on the page :( Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 27, 2006 Share Posted April 27, 2006 This should work:[code]<?phpprint"Blog now online! <a href=\"#blog\">full story...</a>";print"RSS News feed avaiable! <a href=\"#rss\">full story...</a>";print"Guestbook & Forums go live! <a href=\"#forum\">full story...</a>";print"Site Launch!<a href=\"#launch\"> full story...</a>";?>[/code]Also as its just html there is noneed to use the print statement at all just do this:[code]Blog now online! <a href="#blog">full story...</a>RSS News feed avaiable! <a href="#rss">full story...</a>Guestbook & Forums go live! <a href="#forum">full story...</a>Site Launch!<a href="#launch"> full story...</a>[/code] Quote Link to comment Share on other sites More sharing options...
Rawns Posted April 27, 2006 Author Share Posted April 27, 2006 [!--quoteo(post=369171:date=Apr 27 2006, 12:27 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 27 2006, 12:27 PM) [snapback]369171[/snapback][/div][div class=\'quotemain\'][!--quotec--]Also as its just html there is noneed to use the print statement at all just do this:[code]Blog now online! <a href="#blog">full story...</a>RSS News feed avaiable! <a href="#rss">full story...</a>Guestbook & Forums go live! <a href="#forum">full story...</a>Site Launch!<a href="#launch"> full story...</a>[/code][/quote]Sorry to seem stupid but this is new to me, I take it i include that code within the <?php ?> tags?Still does not work :( Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 27, 2006 Share Posted April 27, 2006 The most simplest way of doing this is to have each php file set up like this:[code]<?php //Any php stuff be done here?><html><head> <title>my page title</title></head><body> blah blah blah more html and some more <?php include("news.php"); ?></body></html>[/code]That way all your HTML can be written as normal. All you have to do is add one line (in above example, its near the bottom) to include into the script one file called "news.php" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.