PHP - Include Php File In Html: Why Does It Not Work?
This is most likely a noob question, but... why does it not work?
<html> <head> </head> <body style="background-color:#fff;margin:0"> <div style="border-top:1px solid #404040"> 1. JS: source file <br /> <script type="text/javascript" src="test2.js"/> </script> <br />----<br /> 2. PHP: source file<br /> <script language="php" src="test.php"/> </script> <br />----<br /> 3. JS: script inside<br /> <script type="text/javascript"> document.write('<b></br></br>Hello World</br></b>'); </script> <br />----<br /> 4. PHP: script inside <br /> <script language="php"> echo("Hello World"); print "hello world"; </script> <br />----<br /> </div></div></body></html> with the test.php file in same dir (using MAMP), the test.php does work when loading the file directly: <?php echo("Hello World"); ?> Similar TutorialsHello So in my index.php code i include('somefile.html');. In the html file itself there is an <img src="/images/picture.jpg">. When looking at index.php on a browser, the html looks fine everything loaded fine except for the <img> There is a little broken image link displayed on the page. i checked through the browser if i mistyped the img src link but somefile.html in the browser displays the image fine. But if i try to display the img in the html file through the php file, its a broken link. Any reason why this is happening? Am I missing something here? Thanks in advance. Hello All,
I have been going crazy trying to figure this out, I hope someone can help me out
I have header and footer.php files that on all my pages I get them to load with include,
but for some strange reason, this certain page it will not load I did some research and apparently theres problems with div and php, does anyone know how to make this work?
Thank you in advance,
Elaine
Attached Files
test.txt 4.81KB
7 downloads For some reason this wont work.. Index is jsut returned blank ... Hmm Index.php : <?php include("http://www.website.com/cookie.php"); ?> Cookie.php: <?php if (isset($_COOKIE["background"])) $background = $_COOKIE['background']; else $background = " bgcolor='#FFFFFF'"; ?> It works perfectly if I just enter the code without using a include ... Code for index.php: Code: [Select] <html> <head> <title>Outer World Investigation Agency</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <center> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td> <ul id="menu"> <li><a href="index.html" class="home"></a></li> <li><a href="mkvsdc.html" class="mkvsdc"></a></li> <li><a href="mk2011.html" class="mk2011"></a></li> <li><a href="mkr.html" class="mkr"></a></li> </ul> </td> </tr> </table> <div id="div-name"> <?php include("mainpage.html"); ?> </div> </center> </body> </html> How can I make the links within the included HTML file (mainpage.html) open its contents within itself as if it were a separate frame from my index.php file? Whenever I click a link that's in mainpage.html it opens the link and my PHP file is gone. My PHP file includes a menu that I don't want to have to re-write over and over again in each HTML page. I am incorporating a very basic 'include' statement on a new site. One 'include' calls up menu.php and the second calls up article.php. Both of these files are located in the same file folder as all the pages for this site.
On the index.php page, everything works as expected and both files are showing like they are suppose to. However, the article.php file is not showing up on subsequent pages while the menu.php seems to work fine.
Now I am a complete moron when it comes to php so I have no clue what the problem is or how to fix it so I would really appreciate any help I can get to fix this.
The site is at http://pickmysmoker.com
My code for article 'include' is:
<div id="sidebar" class="link-box"> Code: [Select] <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>----Index----</title> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <link href="file:///H|/10109/10109/10109/WITHOUT_FLASH/style.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff" onLoad="MM_preloadImages('file:///H|/10109/10109/10109/WITHOUT_FLASH/images/l1-1.gif')"> <table width="766" style="height:100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="766" style="height:850px" valign="middle"> <table width="766" style="height:850px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="766" style="height:299px" valign="top"> <table width="766" style="height:299px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="45" style="height:299px" valign="top"></td> <td width="680" style="background-image: url(file:///H|/10109/10109/10109/WITHOUT_FLASH/images/fl.jpg); background-repeat: no-repeat; background-position:;height:299px" valign="top"> <table width="680" style="height:299px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="680" style="height:97px" valign="top"> <table width="680" style="height:97px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="537" style="height:97px" valign="top"> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/logo.jpg" style="margin-left:10px; margin-top:29px"><br> </td> <td width="143" style="height:97px" valign="top"> <a href="#"><img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/p-h.gif" style="margin-left:px; margin-top:55px"></a><img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/p-l.gif" style="margin-left:17px; margin-top:55px"><a href="#"><img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/p-m.gif" style="margin-left:17px; margin-top:55px"></a><img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/p-l.gif" style="margin-left:17px; margin-top:55px"><a href="#"><img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/p-s.gif" style="margin-left:16px; margin-top:55px"></a><br> </td> </tr> </table> </td> </tr> <tr> <td width="680" style="height:202px" valign="top"> <table width="680" style="height:202px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="238" style="height:202px" valign="top"> <?php include("menu.php"); ?> </td> <td width="442" style="height:202px" valign="top"> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/slogan.jpg" style="margin-left:px; margin-top:62px"><br> </td> </tr> </table> </td> </tr> </table> </td> <td width="41" style="height:299px" valign="top"></td> </tr> </table> </td> </tr> <tr> <td width="766" style="height:3px" valign="top"></td> </tr> <tr> <td width="766" style="height:548px" valign="top"> <table width="766" style="height:548px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="55" style="height:548px" valign="top"></td> <td width="659" style="height:548px" valign="top"> <table width="659" style="height:548px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="659" style="height:435px" valign="top"> <table width="659" style="height:435px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="181" style="height:100%" valign="top"> <table width="181" style="height:100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#E9E9E9" width="181" style="background-image: url(file:///H|/10109/10109/10109/WITHOUT_FLASH/images/m1-b.gif); background-repeat: no-repeat; background-position: bottom;height:100%" valign="top"> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/t1.gif" style="margin-left:px; margin-top:px"><br> <div class="m_text" style="margin-left:25px; margin-top:30px; margin-right:15px; margin-bottom:10px"> <strong class="ls_text">[ 12.11.2005 ]</strong><br> <br style="line-height:4px"> <a href="#" class="h_text">Vestibulum ante ipsum primis faucibu</a><br> <br style="line-height:4px"> Fusce feugiat maleda odio. Morbi nunc odio, gvida mrsus necluc tus a, lorem. Mcenas tristique orci ac sem.<br> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/line.gif" style="margin-left:px; margin-top:18px"><br> <br style="line-height:19px"> <strong class="ls_text">[ 12.11.2005 ]</strong><br> <br style="line-height:4px"> <a href="#" class="h_text">Vestibulum ante ipsum primis faucibu</a><br> <br style="line-height:4px"> Fusce feugiat maleda odio. Morbi nunc odio, gvida mrsus necluc tus a, lorem. Mcenas tristique orci ac sem.<br> <div align="left" class="_text" style="margin-left:0px; margin-top:30px"><img alt="" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/a.gif" hspace="0" vspace="0" border="0" align="left" style="margin-right:6px; margin-top:5px"><a href="#" class="l_text">more news</a></div> </div> </td> </tr> <tr> <td width="181" style="height:71px" valign="top"> <a href="#"><img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/b1.jpg" style="margin-left:px; margin-top:7px"></a><br> </td> </tr> </table> </td> <td width="7" style="height:435px" valign="top"></td> <td width="471" style="height:100%" valign="top"> <table width="471" style="background-image: url(file:///H|/10109/10109/10109/WITHOUT_FLASH/images/m2-dr.gif); background-repeat: repeat-y; background-position:;height:100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="m_text" width="471" style="background-image: url(file:///H|/10109/10109/10109/WITHOUT_FLASH/images/m2-b.gif); background-repeat: no-repeat; background-position: bottom;height:100%" valign="top"> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/t2.gif" style="margin-left:px; margin-top:px"><br> <div align="left" class="_text" style="margin-left:20px; margin-top:20px; margin-right:35px; margin-bottom:px"> <img alt="" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/p1.jpg" hspace="0" vspace="0" border="0" align="left" style="margin-right:10px; margin-top:0px"> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/spacer.gif" width="1" height="7"><br> <strong>Ultricies pharetra magna, donec acsan malada <br> Donec sit amet eros, sit amet. </strong><br> <br style="line-height:6px"> Consectetuer dipiscing elit. Mauris in fermen tum dictum.<br> magna <a href="#" class="h_text" style="text-decoration:none">(sed laoreet aliquam leo tellus)</a> dolor, dapibus.<br> eget, elementu vel, cursus eleifend, elit. Aenean auctor wisi et urna erat volutpat.<br> <div align="right" class="_text" style="margin-left:0px; margin-top:6px"><img alt="" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/a.gif" border="0" style="margin-right:6px; margin-top:0px"><a href="#" class="l_text">learn more about us</a></div> </div> <img alt="" border="0" src="file:///H|/10109/10109/10109/WITHOUT_FLASH/images/t3.gif" style="margin-left:px; margin-top:24px"><br> <div style="margin-left:25px; margin-top:22px; margin-right:px; margin-bottom:25px"> <table width="" style="height:px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="223" style="height:px" valign="top"> <ul class="lt_text" style="margin-left:px; margin-top:px; margin-bottom:2px"> <li style="margin-top:0px"><a href="#" class="lt_text">Fusce feugiat malesada odio </a></li> <li><a href="#" class="lt_text">Morbi nunc odio, gravida at </a></li> <li><a href="#" class="lt_text">Cursus necluc tus a, lorem</a></li> <li><a href="#" class="lt_text">Maecenas tristique orci ac sem</a></li> <li><a href="#" class="lt_text">Duis ultricies pharetra.</a></li> </ul> </td> <td width="" style="height:px" valign="top"> <ul class="lt_text" style="margin-left:px; margin-top:px; margin-bottom:2px"> <li style="margin-top:0px"><a href="#" class="lt_text">Fusce feugiat malesada odio </a></li> <li><a href="#" class="lt_text">Morbi nunc odio, gravida at </a></li> <li><a href="#" class="lt_text">Cursus necluc tus a, lorem</a></li> <li><a href="#" class="lt_text">Maecenas tristique orci ac sem</a></li> <li><a href="#" class="lt_text">Duis ultricies pharetra.</a></li> </ul> </td> </tr> </table> </div> </td> Been using these includes in php4 for a long time, but they don't work in php5. Page loads, but included code is blank. Code: [Select] <?php include("http://www.xxxxxxxx.org/header.php"); ?> Hi I am trying to incorporate a login form on my main page from WHMCS but nothing happens I did an include ('login2.php'); and in that login2.php here is the code: Code: [Select] <?php echo date("l F jS Y "); require("./billing/dbconnect.php"); require("./billing/includes/functions.php"); require("./billing/includes/clientareafunctions.php"); if ($_SESSION['uid']) { $result = mysql_query("SELECT firstname,lastname FROM tblclients WHERE id=" . $_SESSION['uid'] . ""); $data = mysql_fetch_array ($result); echo "<hr/><strong>Welcome Back</strong><br>"; echo "<strong>{$data['firstname']}</strong> "; echo "<strong>{$data['lastname']}</strong><br><br>"; echo "<br><br><form method=post action=http://store.crytell.com/billing/logout.php><input type=submit class=submitbutton value=Logout /></form>"; } else { echo '<form method="post" action="http://store.crytell.com/billing/dologin.php?goto=clientarea"> <input type="hidden" name="token" value="##removed##" /> Email Address: <input type="text" name="username" size="50"><br> Password: <input type="password" name="password" size="20"><br> <input type="submit" value="Login"> </form>'; } ?> when I go directly to the login script it works but when I include it in my homepage nothing happens any help? I'm using XHTML 1.0 Transitional and in a line of my code I have used: "<?php include ("drop_down_menu.php"); ?>" I've tried changing the file type to .html but it doesn't work either, unless I actually copy and paste the content in the index file. \= Is it XHTML 1.0 Transitional that doesn't allow this? I've previously worked with HTML 4.01 Transitional and it worked. I have a php file that generates a string that I need to use in a .js (javascript)file. Being that php developers sometimes using javascript with php, Im hoping someone can help me with this, cause i dont know any javascript. Code: [Select] //This is the varible inside the .js file var suggestionText = "I need to be able to include my string generated by the php file here..."; Can I include a class file in the same page that I use an instance of the same class with my action attribute with my form. Here's the code Code: [Select] <?php include 'Resources/User.php';?> <html> <head> <title></title> <link href="stylesheets/styles.css" rel="stylesheet" type="text/css"/> </head> <body> <form action = "Resources/testClass.php" method="post" enctype="multipart/form-data"> <label>First Name: </label> <input type="text" name="fname" id="fname" size="25" maxlength="25"/> <label>Last Name: </label> <input type="text" name="lname" id="lname" size="25" maxlength="25"/> <label>Email: </label> <input type="text" name="email" id="email" size="25" maxlength="40"/> <label>Username: </label> <input type="text" name="username" id="username" size="25" maxlength="32"/> <label>Password: </label> <input type="password" name="password" id="password" size="25" maxlength="32"/> <label>Re-enter Password: </label> <input type="password" name="conf_pass" id="conf_pass" size="25" maxlength="32"/> <br /><br /> <input type="submit" name="submit" id="submit" value="Register"/> <input type="reset" name="reset" id="reset" value="Reset"/> </form> </body> </html> www.desmond-otoole.co.uk/secure/securefunctions.php /bank/admin/index.php what should I do in the index.php file to access securefunctions.php
require("../secure/SecureFunctions.php"); Nothing seems to work
I just get a stupid google chrome page saying Hello, Im trying to pass a variable to a newly created page using GET. Code: [Select] $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title'>" . $nt[$i] . "</a>" . "<br/>"; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); header.php Code: [Select] <head> <?php $title = $_GET['Title']; ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p>HEADER UPDATED!</p> <p>TESTING - the heading below should read (title goes here in capital letters)</p> <?php <h1>$title</h1> ?> //This is line 12 </body> </html> Im getting the error; Parse error: syntax error, unexpected '<' in D:\Hosting\3753557\html\1pw\mexican.php on line 12 I suspect that I have my syntax muddled in header.php? Is there a better way to pass variables to a newly created page? (fopen). Many thanks for any ideas. I want to include a php file after an succesfully login. Let's suposed that I have a login form on index.php. If the login was ok I want to include a php file with some content instead of the login form. Something like: Code: [Select] <? if($_POST['ok']){ require('content.php'); } else { //login form } ?> It's ok to include in the code the name of the file that you have on server ? From security point of view. Thanks How do I include a file that is located two directories above the file that I want to include the file into? My absolute hosting path is /home/content/52/8840652/html if this would be of any use. I'm not quite sure about the PHP include functions. Any help would be greatly appreciated, Thanks! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=308660.0 Hello, I have a simply query that will if a simple two different things: Code: [Select] $cssyn = mysql_query("SELECT `12` FROM `12345` WHERE `abc` = '$_SESSION[number]'"); $cssy = mysql_fetch_row($cssyn); if($cssy[0] == "YES") { echo "Yes"; } else { echo "No"; } The YES or NO result is stipulated earlier on so thats not the problem. But basically before I added the if statement simply would have echoed a table with all the rows etc from another query. However I would like to give the user a choice between echoeing the results into one table or a neater two. I have separated the code for the table and the queries into two separate files but say if I use: file_get_contents then it just prints the HTML and doesnt actually populate it will the queried parts. Nor if I use something like include() then it wont echo anything, which it wouldnt unless called so what I am asking is: Is there a way to get EVERYTHING from the file if the answer is YES or the other file if NO. Hi I'm in a need of help here, I need to inluded this: "http://site.com/products.php?do=groups&groupid=2" in a a tpl file. Any way that this can be done? an example would be greatly appreciate it. cheers |