Jump to content

Can HTML use PHP codes?


Recommended Posts

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 post
Share on other sites

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 post
Share on other sites
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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...