The Sea King Posted November 15, 2007 Share Posted November 15, 2007 Can HTML use PHP codes? Link to comment Share on other sites More sharing options...
Synook Posted November 15, 2007 Share Posted November 15, 2007 Uh... what do you mean? You can use PHP to generate HTML... Link to comment Share on other sites More sharing options...
Ingolme Posted November 15, 2007 Share Posted November 15, 2007 You're allowed to write PHP within HTML. For example:<?php $link = "http://www.google.com"; $linkname = "Google";?><a href="<?php echo $link;?>"><?php echo $linkname; ?></a> Link to comment Share on other sites More sharing options...
Reg Edit Posted November 15, 2007 Share Posted November 15, 2007 PHP is an example of server-side scripting. Server-side scripting means that when a web page is requested by a browser, the webserver executes scripts embedded in the page, and then sends the resulting html to the browser. Have a look at the PHP tutorial where it says more about this. Link to comment Share on other sites More sharing options...
The Sea King Posted November 15, 2007 Author Share Posted November 15, 2007 You're allowed to write PHP within HTML. For example:<?php $link = "http://www.google.com"; $linkname = "Google";?><a href="<?php echo $link;?>"><?php echo $linkname; ?></a>... oh ... then why doesn't cute news work?*posts in their forum* Link to comment Share on other sites More sharing options...
Ingolme Posted November 15, 2007 Share Posted November 15, 2007 It might be because your host doesn't have PHP, or because the code you entered has errors.Actually, you might want to make sure the file is saved with a .php extension and not a .html extension. Like "index.php" and not "index.html" Link to comment Share on other sites More sharing options...
justsomeguy Posted November 15, 2007 Share Posted November 15, 2007 If you're trying to type PHP code into a content management system interface it's probably not going to work, unless the CMS is set up specifically to execute PHP code that you enter. Most CMSs will probably strip the tags and reformat the content before it shows it on screen. Link to comment Share on other sites More sharing options...
The Sea King Posted November 15, 2007 Author Share Posted November 15, 2007 It might be because your host doesn't have PHP, or because the code you entered has errors.Actually, you might want to make sure the file is saved with a .php extension and not a .html extension. Like "index.php" and not "index.html"ok... I'll try that.Edit:It didn't work...Why does this one work (Example 1) and the one I try to type in doesn't work. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 15, 2007 Share Posted November 15, 2007 I don't know what I'm supposed to be looking for on that example page and I'm not sure what you've tried either. Let's start at the beginning. Specifically, what are you trying to do? As in the steps you take to do it. Link to comment Share on other sites More sharing options...
The Sea King Posted November 15, 2007 Author Share Posted November 15, 2007 Ok.I am trying to install cute news (or in other words a content management system) on my site.I already uploaded all the files of cute news on my site. It works but only pages example1, example2, and show_news.php .When I try to add it to my site (I copyed it correctly), it doesn't show it.Here's the code I entered: <?PHP $number = "5"; include("/cutenews/show_news.php");?> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 15, 2007 Share Posted November 15, 2007 What do you see when you put that code in? Link to comment Share on other sites More sharing options...
The Sea King Posted November 15, 2007 Author Share Posted November 15, 2007 What do you see when you put that code in?nothing...Link^ I'll have to reupload it.Edit:Uploaded Link to comment Share on other sites More sharing options...
justsomeguy Posted November 15, 2007 Share Posted November 15, 2007 What is the code for index2.php? Aside from the chunk of Javascript before the <html> tag the page looks fine. Link to comment Share on other sites More sharing options...
The Sea King Posted November 15, 2007 Author Share Posted November 15, 2007 The Whole code? <html><body bgcolor="059DC6" background="http://img80.imageshack.us/img80/7098/lwbackgroundpz4.jpg"><style type="text/css">table, td {border-collapse: collapse;}a:link {color: #ffffff; text-decoration: none; font-style: italic;}a:visited {color: #ffffff; text-decoration: font-style: italic;}a:hover {text-decoration: underline;}</style><table align="center" width="780" border="1"><tr><td width="780" height="100" background=""> </td></td></tr></table><table align="center" border="1" width="780"><tr><td width="30" background="http://img119.imageshack.us/img119/9986/lwleftls1.png"></td><td width="100"><table border="0" bgcolor="0076A3"><tr><td valign="top"><div style="background: url(http://img402.imageshack.us/img402/6615/menubackgroundom0.jpg) top left"><div style="background: url(http://img489.imageshack.us/img489/3563/menubacklb1.jpg) top left repeat-x;"><img src="http://img98.imageshack.us/img98/2920/menumainqu8.png"><br><br><a href="/lw/s1/index.html">Home</a><br><a href="/lw/s1/staff.html">Staff</a><br><a href="/lw/s1/credits.html">Credits</a><br><a href="/lw/s1/affiliates">Affiliates</a><br><a href="http://www.freewebs.com/">Newspaper<br><a href="http://www.pbwiki.com/">Wiki</a><br><a href="http://www.ipbfree.com">Forum</a><br><a href="/index.html">Entrance</a><br><br><img src="http://img253.imageshack.us/img253/3198/menugoldensunre5.png"><br><br><a href="/lw/s1/gs1/introduction.html">Introduction</a><br><a href="/lw/s1/gs1/characters.html">Characters</a><br><a href="/lw/s1/gs1/maps.html">Maps</a><br><a href="/lw/s1/gs1/djinn.html">Djinn</a><br><a href="/lw/s1/gs1/weapons.html">Weapons</a><br><a href="/lw/s1/gs1/armor.html">Armor</a><br><a href="/lw/s1/gs1/items.html">Items</a><br><a href="/lw/s1/gs1/walkthrough.html">Walkthrough</a><br><br><img src="http://img240.imageshack.us/img240/7639/menulostagenc8.png"><br><br><a href="/lw/s1/gs2/introduction.html">Introduction</a><br><a href="/lw/s1/gs2/characters.html">Characters</a><br><a href="/lw/s1/gs2/maps.html">Maps</a><br><a href="/lw/s1/gs2/djinn.html">Djinn</a><br><a href="/lw/s1/gs2/weapons.html">Weapons</a><br><a href="/lw/s1/gs2/armor.html">Armor</a><br><a href="/lw/s1/gs2/items.html">Items</a><br><a href="/lw/s1/gs2/walkthrough">Walkthrough</a><br><br><img src="http://img265.imageshack.us/img265/4369/menuothersl7.png"><br><br><a href="/lw/s1/other/fanart.html">Fan Art</a><br><a href="/lw/s1/other/storyWriting.html">Story Writing</a><br><a href="/lw/s1/other/music.html">Music</a><br><a href="/lw/s1/other/videos.html">Videos</a><br><a href="/lw/s1/other/downloads.html">Downloads</a><br><a href="/lw/s1/other/helpOnOtherStuff.html">Help on Other Stuff</a></div></div></td></table><td width="30" background="http://img112.imageshack.us/img112/2989/lwrightgg0.png"> </td><td valign="top" width="690" background="http://img267.imageshack.us/img267/3472/lwcontextxl3.jpg" style="padding-left: 10px"><h5><script type="text/javascript">var d=new Date()var month=new Array(12)month[0]="January"month[1]="February"month[2]="March"month[3]="April"month[4]="May"month[5]="June"month[6]="July"month[7]="August"month[8]="September"month[9]="October"month[10]="November"month[11]="December"var weekday=new Array(7)weekday[0]="Sunday"weekday[1]="Monday"weekday[2]="Tuesday"weekday[3]="Wednesday"weekday[4]="Thursday"weekday[5]="Friday"weekday[6]="Saturday"document.write("Today is " + weekday[d.getDay()] + " " + month[d.getMonth()] + " " + [d.getDate()] + "th " + ", " + [d.getFullYear()])</script></h5><b>News and Updates</b><br><?PHP $number = "5"; include("/cutenews/show_news.php");?></td><td width="30" background="http://img112.imageshack.us/img112/2989/lwrightgg0.png"></tr></table><table align="center" width="780" border="1"><tr><td width="25" height="30" background="http://img125.imageshack.us/img125/1142/lwtopleftyg6.png"> </td><td width="725" height="30" background="http://img113.imageshack.us/img113/4351/buttomzr1.jpg"> </td><td width="23" height="30" background="http://img125.imageshack.us/img125/1142/lwtopleftyg6.png"> </td></tr></table><center><span style=font-size:8pt></span></center> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 15, 2007 Share Posted November 15, 2007 Just as I thought, your host is adding the Javascript to the top of your page. I hate that, it means that all of your pages on their site will be rendered in quirks mode in IE. You can have an XHTML strict site that otherwise validates perfectly and IE will still use quirks mode with it because they added their Javascript.Anyway, what's the source for the show_news file? Your file is fine. Your host sucks, but your file is fine. Link to comment Share on other sites More sharing options...
The Sea King Posted November 15, 2007 Author Share Posted November 15, 2007 ...so the problem is my host?*starts to look for a better host* Link to comment Share on other sites More sharing options...
justsomeguy Posted November 16, 2007 Share Posted November 16, 2007 That wouldn't cause the PHP to fail. The show_news file is getting included, it's just not doing anything. The number might have something to do with it. If you can post the show_news file then we can figure out what it's doing with the number. Link to comment Share on other sites More sharing options...
The Sea King Posted November 16, 2007 Author Share Posted November 16, 2007 Ok. <?PHPerror_reporting (E_ALL ^ E_NOTICE);$cutepath = __FILE__;$cutepath = preg_replace( "'\\\show_news\.php'", "", $cutepath);$cutepath = preg_replace( "'/show_news\.php'", "", $cutepath);require_once("$cutepath/inc/functions.inc.php");require_once("$cutepath/data/config.php");// If we are showing RSS, include some need variables.if($template == 'rss'){ include("$cutepath/data/rss_config.php");}//----------------------------------// Check if we are included by PATH//----------------------------------if($HTTP_SERVER_VARS["HTTP_ACCEPT"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_CHARSET"] or $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"] or $HTTP_SERVER_VARS["HTTP_CONNECTION"]){ /* do nothing */ }elseif(eregi("show_news.php", $PHP_SELF)){die("<h4>CuteNews has detected that you are including show_news.php using the URL to this file.<br>This is incorrect and you must include it using the PATH to show_news.php</h4><br>Example:<br>this is <font color=red>WRONG</font> :Â Â <?PHP include(\"http://yoursite.com/cutenews/show_news.php\"); ?><br>this is <font color=green>CORRECT</font>:Â Â <?PHP include(\"cutenews/show_news.php\"); ?><br><br><BR>// <font size=2>if you think this message shouldn't be shown, open show_news.php and delete it from there</font>");}//----------------------------------// End of the check//----------------------------------if(!isset($subaction) or $subaction == ""){ $subaction = $POST["subaction"]; }if(!isset($template) or $template == "" or strtolower($template) == "default"){ require_once("$cutepath/data/Default.tpl"); }else{ if(file_exists("$cutepath/data/${template}.tpl")){ require("$cutepath/data/${template}.tpl"); } else{ die("Error!<br>the template <b>".htmlspecialchars($template)."</b> does not exists, note that templates are case sensetive and you must write the name exactly as it is"); }}// Prepare requested categoriesif(eregi("[a-z]", $category)){ die("<b>Error</b>!<br>CuteNews has detected that you use \$category = \"".htmlspecialchars($category)."\"; but you can call the categories only with their <b>ID</b> numbers and not with names<br> example:<br><blockquote><?PHP<br>\$category = \"1\";<br>include(\"path/to/show_news.php\");<br>?></blockquote>");}$category = preg_replace("/ /", "", $category);$tmp_cats_arr = explode(",", $category);foreach($tmp_cats_arr as $key=>$value){ if($value != ""){ $requested_cats[$value] = TRUE; }}if($archive == ""){ $news_file = "$cutepath/data/news.txt"; $comm_file = "$cutepath/data/comments.txt";}else{ $news_file = "$cutepath/data/archives/$archive.news.arch"; $comm_file = "$cutepath/data/archives/$archive.comments.arch";}$allow_add_comment = FALSE;$allow_full_story = FALSE;$allow_active_news = FALSE;$allow_comments = FALSE;//<<<------------ Detarime what user want to doif( $CN_HALT != TRUE and $static != TRUE and ($subaction == "showcomments" or $subaction == "showfull" or $subaction == "addcomment") and ((!isset($category) or $category == "") or ($requested_cats[$ucat] == TRUE ) ) ){ if($subaction == "addcomment"){ $allow_add_comment = TRUE; $allow_comments = TRUE; } if($subaction == "showcomments"){ $allow_comments = TRUE; } if(($subaction == "showcomments" or $allow_comments == TRUE) and $config_show_full_with_comments == "yes"){$allow_full_story = TRUE; } if($subaction == "showfull") $allow_full_story = TRUE; if($subaction == "showfull" and $config_show_comments_with_full == "yes") $allow_comments = TRUE;}else{ if($config_reverse_active == "yes"){ $reverse = TRUE; } $allow_active_news = TRUE;}//----------->>> Detarime what user want to dorequire("$cutepath/inc/shows.inc.php"); if($_GET['archive'] and $_GET['archive'] != ''){ $archive = $_GET['archive']; } // stupid fix ?unset($static, $template, $requested_cats, $category, $catid, $cat,$reverse, $in_use, $archives_arr, $number, $no_prev, $no_next, $i, $showed, $prev, $used_archives);?><!-- News Powered by CuteNews: [url="http://cutephp.com/"]http://cutephp.com/[/url] --> Link to comment Share on other sites More sharing options...
Synook Posted November 16, 2007 Share Posted November 16, 2007 Uh... try <?PHP$number = "5";include("cutenews/show_news.php");?> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 16, 2007 Share Posted November 16, 2007 Add this to the top of your index file:error_reporting (E_ALL); Link to comment Share on other sites More sharing options...
The Sea King Posted November 16, 2007 Author Share Posted November 16, 2007 Uh... try<?PHP$number = "5";include("cutenews/show_news.php");?> ok. I'll try that. Link to comment Share on other sites More sharing options...
The Sea King Posted November 17, 2007 Author Share Posted November 17, 2007 It worked. But when I closed the </body></html> it disappeared...again...Edit:I figured out the problem. It was because I placed the file in a sub-folder....not in main one. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.