Includes In Php As Cgi
I am in the process of moving a site to a new server.
On the old server, these two functions:
<?include("header.shtml");?>
and
<?include("footer.shtml");?>
allowed me to successful include a simple header and footer on every
page of the site.
However: on the new server, php is installed as cgi.
What function will allow me to successfully include the header and
footer files with this configuration? The host swears that shtml works
perfectly as an include for the php installed as cgi configuration --
but I cannot get it to work with this standard command.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
PHP Includes Vs. Server Side Includes
Up until now I've been using the PHP include(" "); function to parse items such as navigation bars into my web pages. But I've heard a lot about the SSI way to do it, and I was wondering which is better. For example, is SSI faster because the server doesn't have to load the PHP (if it does at all). So which is generally better for that specific task?
PHP Includes
Heres my prob. Ive got for eg a structure like this. /index.php /info.php /inc/database.php /inc/header.php /inc/footer.php Say index.php includes header.php and footer.php. Then in header.php that includes database.php and info.php. I cant get the paths to work and ive completely forgotten how to sort it. Its doing my head in because I cant move forward in the development of the project.
PHP Includes And SEO
I want to use PHP includes for the menus and header on my next site, something like this: <?php include ("menu.html"); ?> in the main pages with the menu and headers on a separate files for ease of editing. Just a bit concerned as to whether search engine bots and spiders will be able to index the links and see the content of the include okay.
Includes
when using includes, will suing the full url to the include file make any difference from if ui just used the something like folde/filename?
Includes
i am using an the following code with an include file on every page on my site... //GET NAME OF THIS PAGE IN CASE CONNECTION FAILS $failedpage = basename($PHP_SELF); //INCLUDE THE GENERAL FUNCTIONS PAGE include("../resources/functions.php"); //CONNECT TO DATABASE Connectme($failedpage); what happens here is that the page gets its own name, it includes the functions page which contains the function Connectme which of course connects it to the database. it then calls the function Connectme passing the name of the page the call is coming from as $failedpage. So the first thing every page does is connect to the database, if the connect fails then there is a clause in the Connectme function which waits a few seconds and then retries. now this works fine but i have noticed something very odd happening in the functions.php. the function.php is an include file, before it makes the connect in the function Connectme it includes a file called myconst.h which contains all the passwords for the connection to the database. so the include file function.php has an include file myconst.h, with me so far? the myconst.h resides in the same folder as function.php and so the include is simply... include("myconst.h"); however it fails to find it, if i change the include to... include("../resources/myconst.h"); which is the same thing as the folder it resides in is called resources, it works? now i'm not mad! i've tested it about 5 times and systematically every time the first fails and the second works!
PHP Includes
Basically I have a layout index page. What I want to accomplish is display my content pages WITHIN my index page and I dont want to use iframes. Code: <?php if(strstr($id, "..") || $id[0]=="/") $id = ""; if(empty($id)) $id = "/home/vbd/public_html/home.html"; else { $id = $id . ".html"; } if(is_file("$id")){ include("$id"); } else include ("404error.html");?> I'm formatting my links like this: Code: <a href="index.php?id=news">News</a> And heres what's happening, the home page work as it should but none of the links are working.
PHP Includes
I have a configuration file called config.php" that I would like all my pages to have. The problem with it is that I have to include it in all my pages and have to specify the exact directory wherever it's located and I have my files throughout different files in the filesystem and it becomes a tedious job. So my question is, is there a way to have php include the file on all your pages in a specific directory recursivly or is there an apache setting through .htaccess that can maybe pull this off?
Using Includes
I have set up my includes outside the public_html directory in directory phpincludes. When I access index.php in public_html the includes work. I also have a second directory inside public_html, dir2 and want to access these same includes. I've used an .htaccess file to set the path to the includes from public_html. I don't think I need another .htaccess file inside dir2 since I'm under the impression the directives cascade up the root tree. Can someone point me in the right direction. The PHP files are a counter using MySQL. I would like to use them from several different directories.
PHP Includes
Is it necessary to have your file named *.php to use PHP code in it, such as for includes? Can't any extension be used?
PHP Includes
I don't want to use Server-Side Includes and recently found out about PHP Includes. (I am new to PHP :P) I've heard that it is simple. If you can provide me with a link to a great tutorial on how I should get started, that would be great.
Includes
I have 3 files Index.php, x.php and login/Login.php in Login.php <?php require_once "../x.php"; ?> Index.php <?php require_once "loginLogin.php"; ?> when executing Index.php error is Failed opening required '../x.php' I can of course say <?php require_once "x.php" ?> in Login.php, then Index.php would load fine.. However if I load loginLogin.php independently, x.php would not be found. So what should I do?
Using Includes
When I use includes on my site, I have usually had the conf.php file in the same folder as the web page which will be using it and everything has worked fine, but when I have tried to tidy up my folder structure and put all of the includes in the same folder, the page gives me an error. The code which I am using is below. include("/../includes/conf.php");
Includes . . .
In the site I am building I am using templates to make it easier, what do you think is the best way to do it, put the header and footer together and include the body, or include the header and footer in the body? For example: include ('header.php'); Body Here include ('footer.php'); OR Header here include ('body.php'); Footer here
About Partial Includes
I tried the following code, which simply includes all the contents from the other file. I want it NOT to include HTML code AFTER <END HTML DATA> tag in the other file. Please let me know if the code needs to be corrected, or I am doing something wrong. <? $off_site = "./"; $data_start = "<!-- START HTML DATA -->"; $data_end = "<!-- END HTML DATA -->"; $fp = fopen ("$off_site$page", 'r') or die("Unable to open file $off_site$page for reading"); $readData = false; while (!feof ($fp)) { $buf = trim(fgets($fp, 4096)); if ($readData) { echo $buf; continue; } if ($buf == $data_start) { $readData = true; continue; } if ($buf == $data_end) { $readData = false; continue; } } fclose ($fp); ?>
Perl Includes
Am I using this right, trying to get a cgi/perl script to run as an include on a php page virtual("./cgi-bin/schlabo/potd/potd_thumbnail.pl"); Im pretty sure thats correct but when i use it, its read as text on the page and doesnt run the script.
Are Mysql Includes Possible?
I use the php include function regularly for headers and other common page elements. What I would like to do is "include" my mysql queries too. i.e. mysql_select_db($database_name, $mydb); $query_rsCatdept = "SELECT category.name FROM category WHERE category.categoryID = $pagevar"; $rsCatdept = mysql_query($query_rsCatdept, $mydb) or die(mysql_error()); $row_rsCatdept = mysql_fetch_assoc($rsCatdept); $totalRows_rsCatdept = mysql_num_rows($rsCatdept); $catname = $row_rsCatdept['name']; The $pagevar variable would change depending on what page my mysql query was "included". This way I can create a "commonmysql.php" page that holds all my queries, and if i decide to change them, I only have to do it once.
Breadcrumbs And Includes
One of our clients who has an existing site would like for us to implement a breadcrumbs line. My problem here is that his site was built on the basis of a single layout file and inumerous include files and no directories. One single include file may contain different aspects of different pages. A real mess from my point of view but there is little I can do at this stage to recode evrything of course. Well... now onto my problem... I actually have no idea on how to code a breadcrumbs for this very specific case, I mean from what I understood existing breadcrumbs scripts list items on a directory or file basis... Not sure how to work this out with a single layout file and includes inside it...
XML Includes In PHP Causes Failure.
First off, I'm posting this question for a friend that doesn't have access to the news groups. Problem: Using PHP as the base and has several PHP < includes > for various functions, all this by its self works just fine. Failure occurs on adding the XML include. Here's the wierd: If all the PHP includes are removed/commented out, the XML includes work fine. As soon as you replace/uncomment the PHP includes everything fails.
Includes In Libraries
A fairly simple question: I have a library A which depends on library B and C. Currently I have: <?php include("A.inc.php"); include("B.inc.php"); include("C.inc.php"); ?> ....in my HTML. This needs changing to: <?php include("../A.inc.php"); include("../B.inc.php"); include("../C.inc.php"); ?> ....if I call it from deeper in the directory tree. I don't want lots of includes in my HTML. I want to write: <?php include("A.inc.php"); ?> ....and to have the other includes in the "A.inc.php" file. However if I put: include("B.inc.php"); include("C.inc.php"); ....in the library, it doesn't fild the files when included using: <?php include("../A.inc.php"); ?> ....in an HTML file some distance from the root. I don't want to wire absolute paths in. I *could* pass the "../" in as a method parameter - but that seems like a total mess. What is the best way to resolve this issue?
Includes In An Array
I'm trying to have rotating server side includes. I've got this far, I've got the code in place to show the words one, two, three and four in rotation. When I replace the words with <?php require_once('rotating_links_01.php');?> it kicks it out because of the extra '. I'm sure I'm not containing it correctly. <?php $links = array('one', 'two', 'three', 'four'); $i = rand(0, count($links)-1); $selectedLinks = $links[$i]; ?>
Php Global Includes?
Isn't there some way to include some php code every time a php script is run without having to put an include statement in the script? All I want to do is set the ORACLE_HOME environmental variable on a development machine. The servers have it compiled into php and it's different on different machines. So programmers using the development platform shouldn't have to set ORACLE_HOME. I've been browsing the php documentation and doing google searches for an hour already. I thought there was a config file somewhere where you could put some php code and it would be run every time a script is run.
Wordpress And PHP Includes
I am currently using wordpress and have it installed to the folder mysite.com/blog/ and would like to have the most recent post appear on mysite.com/news.html Is there any way of doing this. I want the whole post to be displayed including pictures.
With Includes / Font Tag
I was wondering how I would be able to strip the <font> tags from a file when I include it so it can take on the characteristics of my own stylesheet instead of the font tag attributes.
Server Includes?
on SSI or IIS you can do a <!--#INCLUDE FILE="page.html"--> or in Cold Fusion its <CFINCLUDE TEMPLATE="page.html"> what might that be in PHP?
Variables And Includes
<? $variable = 1; include('http://www.website.com/file.php');?> It seems like if I referenced $variable from file.php it should have a value of 1. This does not seem to be the case. Is my assumption wrong? It works on my server, but not on an acquaintances.
What Kind Of Includes Don't Use PHP?
I just moved this site a new server: On the new server, it does not work. Most pages have a top banner and bottom footer that is included. The include works successfully on old server but not on the new one. At first I thought I was seeing PHP includes() and what needed to happen has that the .htacess needed to send all html files to the PHP parser - I'd done this many times before. In fact, I'd done this on my own personal site. So I wrote a ..htaccess file for this to happen. I could not get it to work, though I checked the paths and the capitalization many times. If you look at these pages, you'll see the headers and footers are missing (compared to the same pages shown at the site above): If you look at the source code, all the includes begin to jumpu out at you, including this one at the top and the two at the bottom: <!--#include file="inc_scripts.js" --> <link href="staengl3.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#E8E5D9" onLoad="MM_preloadImages('images/subpage_nav_r1_c1_f2.gif','images/subpage_nav_r1_c2_f2.gif','images/subpage_nav_r1_c3_f2.gif','images/subpage_nav_r1_c4_f2.gif','images/subpage_nav_r1_c5_f2.gif','images/subpage_nav_r1_c6_f2.gif');"> <div align="center"> <table width="740" border="0" cellpadding="10" cellspacing="0" class="borderOuter"> <tr> <td align="center" valign="middle"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="borderOuter"> <tr> <td align="center"> <!--#include file="inc_header_company.htm" --> <!--#include file="inc_nav.htm" --> What kind of include is this, and how do I activate on the new server.?
PHP Includes Question
If my index.php has two includes: require_once( './includes/WebStart.php' ); require_once( "includes/Wiki.php" ); Then each of those have includes, then each of those...... etc. etc. etc.......... Once index.php is called, even if it aborts (not from an error but say by the program's own design), do every single one of my thousands of PHP interlinked files by "require_once" lines get all loaded, compiled, and put into memory?
Includes Across Sub Domains
I have a site www.mysite.com. I have 3 subdomains sub1.mysite.com, sub2.mysite.com and sub3.mysite.com. sub3.mysite.com is password protected. All pages end with .php (ie index.php) I use the following code: <?php include("inc23.inc"); ?> I find that I will require some of the same includes in more than one subdomain. Can I do the following? 1) Create a subdomain called resources.mysit.com with 3 folders - images, includes and stylesheets and use A. <?php include("resources.mysit.com/includes/ inc23.inc"); ?> B. <link rel="stylesheet" type="text/css" href="resources.mysit.com/stylesheets/stylesheetraw.css" /> Instead of <link rel="stylesheet" type="text/css" href="stylesheetraw.css" /> C. In my style sheet use #toparea {background-image: url(resources.mysit.com/images/images/gs1.gif); etc instead of #toparea {background-image: url(images/gs1.gif); etc D Does the fact that one of my subdomains is password protected complicate anything?
Path To Includes
I can't seem to get the path to my include files right. The php app sits in /var/www/html/myapp. I have my include files in /var/www/includes. I've tried every configuration of relative paths to get to them, but nothing works. So I tried the absolute path like this include("/var/www/includes/HtmlFooter.txt") and that doesn't work. I've opened up the permissions all the way on the path and file, but still no luck. I even tried putting the files in "/usr/lib/myapp" and I still can't access them.
Includes Question
I was just wondering ... I use the following a lot: include_once("connectToDB.php"); include_once("some_functions.php"); include_once("HTML_snippets.php"); etc... Can I do this: include_once(http://www.someotherurl.com/HTML_snippets.php); and if so, it is a security risk to have my include files in an unprotected (www or public) directory???? What is the usual setup in terms of access priveleges?
Includes Question
There's 3 files involved: test.php library/myconnect.php library/insert.php test.php contains a form which I've just smacked together to test an insert record function I created in library/insert.php. library/myconnect.php opens a connection my mySQL db. My problem is this. In test.php I'm am including library/myconnect.php and library/insert.php at the top of the script using: include("library/insert.php"); include("library/myconnect.php"); This returns an error in library/myconnect.php like the connection to the database hasn't been opened. If instead of including both files in test.php, I include library/myconnect.php in library/insert.php, everything works but I have to specify the subdirectory to library/myconnect.php and I don't want to do that as it's not portable. Has anyone got any ideas as to why this might be? I've tried using require() as well but no joy!
Function Or Includes?
I'm building my first dynamic web site using MySQL for the database and PHP for rendering the data in my HTML templates. It's a site that shows accomodation listings for a particular region. Here's my question: Currently, I'm not using functions for "resuable code" but instead I'm using required (); and pulling in the query and php rendering code for each new query I need to call on a page. Here's the require call: PHP Code:
PHP - Can I Nest Includes?
Can I include a PHP file from a file that has been included. From the example below, I have a start PHP page with an include to a type of template page, and from page 2, I include a 3rd page. The first include works, but the page 3 is brought in as standard text. Is this a PHP limitation, or do I need to make a change to the PHP config. file? (Page1) <? include("page2.php"); ?> (Page2) <html> <head> <title>Sans Titre</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content="HAPedit 3.1"> </head> <body bgcolor="#FFFFFF"> <? // Your code here echo "<hr /> ". "HAPedit 3.1.11.111 (September 2005 7:03:30 PM)<p>"; ?> requires("page3.php"); </body> </html> (Page3) <? $x = 100; echo $x." This is a test"; ?>
Server Includes
Server Includes were shut off on my site at: http://web.ics.purdue.edu/~cthilges/ Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/lookout/h2/cthilges/www/index.php on line 2 Warning: include(http://web.ics.purdue.edu/~cthilges/header.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/lookout/h2/cthilges/www/index.php on line 2 Warning: include() [function.include]: Failed opening 'http://web.ics.purdue.edu/~cthilges/header.php' for inclusion (include_path='.:') in /home/lookout/h2/cthilges/www/index.php on line 2 I use this feature so that i can have a basic template file for my site with only two includes: <?header=http://web.ics.purdue.edu/~cthilges/header.php> the content <?footer=http://web.ics.purdue.edu/~cthilges/footer.php> With an absolute url as well i never have to count ../../../ What security reason is this disabled? It seems to be a very convenient and irreplaceable feature. I add pages of flashy site code this way.
Php/apache Includes
Not sure if this is an apache configuration or a php configuration problem, i'm hoping someone can help. I'm running a webserver on FreeBSD consisting of apache2 and php4 among other items. I've got a site that has an alias directive defined in httpd.conf like: alias /include "/path/to/directory/include" In that area i have a file header.php which contains standard information i want displayed across my web pages. In my index file i have: <? include "/include/header.php"; ?>
Brackets Across Includes
I am trying to create a user authentication system, and I would like to separate the authentication code into include files. As I see it, the basic flow would go something like this: if (not authentic) { display login } else { display content } I would like to separate this code so that the login bit is in an included file. I imagined the breakup like this: file: [auth_head.php] ----------------------- if (not authentic) { display login } else { ----------------------- file: [auth_foot.php] ----------------------- } ----------------------- So in each file which requires authentication, I can simply include the first bit in the head, the second bit at the bottom, and put the content in the middle. Makes sense, right? Unfortunately, it seems that you cannot continue a { bracket } statement across includes in this manner, as php errors. (It wants you to wrap up your brackets before the end of the file.) Does anyone know of a solution to this problem, or perhaps a work-around?
Includes Not Including..
The problem is with SSI and getting the part that says Scripture Today under the menu. I have it including a file called func.php (attached) but it is not pulling from my server. I have changed directories and done everything I could think of but I still do not understand.
Php Includes/require Once Etc
whats the best way to include code from another file into the php file that will be seen on the site, and what effect does this have on the speed? does it hold it up or delay it at all? e.g. making a login script and if the login is succesfull then include('loginSuccess.php') else not succesfull so include('loginFail.php');
Variables And Includes
I have been trying to program in php for a long time and i feel i am finally getting the hang of many simple things, but as i was making my newest script (most complex.... for me anyway ) I have made a two files, each one REQUIRES the other but they can not be together. An Example of my Problem is: File 1 -----include-----> File 2 ----include-----> File A ----include-----> File B File A and B are included into File 2, File A has variable $example_variable which is required in File B, but for some reason File B can not see this variable. File 2 is then included in File 1, which is the actual page. Is it possible to use variables in one include in another?
Alternative To 'includes'
My server doesn't allow includes across directories on the server. Is there ANY other possible way to accomplish the same thing, without using includes? So far I have tried: - include - include_once - _absolute path_ So yeah. Anyone else know a way to accomplish this?
Checking To See If URL Includes Something
I need a simple script that checks if the URL includes a specific string of text, and if it does, do something, if it doesn't, do something else. I know this can be accomplished with an if/else function, which I can do, but I don't know how to do the checking the URL part.
Using Includes For Queries
I have two queries that I will be running at the top of each page on my site once the user is logged in to pull in different information about them and to show the company's information. Would I be better off having these at the top of each page in the code or having them in includes and calling the includes?
Dependent Includes?
i've got a page someone else built with an include for another file. the include needed a random banner, both jpeg and swf. so i figured that one out - i've set up an include in that file which calls the proper code randomly from a text file, one line with the embed for the swf and one line with the image (both in their own link tag - a href...) so here's the issue - back on the top level, there's another banner which needs to be dependent on the include inside the include. they're in 2 completely different places, so tying them into the same file is not an option.
Includes - But Different Servers
How can I include a .php file which is located on a different server/host? include_once("http://www.domain.com/dir/include_this.php"); The above gives: failed to open stream: Connection refused in...blah blah
Perl Includes In A Php Page
I'm converting some html pages to php pages. The original pages have perl includes in them with this syntax in the html: <!--#exec cgi="/cgi-bin/ads/zonea.pl"--> Of course, such includes in my php pages aren't working. Is it possible to run this perl script and put the results into a php string variable by something like: $variable = system("perl /path_to/cgi-bin/ads/zonea.pl"); that might not be syntacticly correct, but I hope the idea is getting across. I just discovered the answer to my question, and I'll go ahead a post in case some else would like to know, or if someone else knows a better way to do this, but this worked: $variable = echo("perl /path_to/cgi-bin/ads/zonea.pl"); echo $variable; Which printed the banner to the php document just like the ssi did in the original html doc. Hope someone finds it helpful!
Scrolling Results In Includes
I've picked up the development of a php/mysql driven site that uses a header, main and footer include to assemble the page. The main include being either static information pages, or Product details built up from queries to mysql. You can take a look at URL ....there is a holding page on the root so index.php is required. In order to maintain maximum navigation functionality, the client has requested that the displayed product results are scrollable in the center of the page with the menus etc remaining in place around the outside. The area in which the products are displayed is, again, an include, not a frame. So in a nut shell, I'm looking for a custom scroll solution in an include.
Preventing Php Includes From Getting Cached
I am using php includes to breakdown my site so that it's more maintainable. But these are getting cached on the server-side, therefore, the changes I make do not show up. Is there a way that I can prevent my php code from getting cached?
Using An Array Variable From An Includes?
I am making an array of browsers that do not support AJAX. I want to of course have this as an includes somewhere so I don't have to maintain several lists simultaneously. I'm not sure how to compare the useragent ($useragent) against this array ($useragents['noajax']) and I've tried something like... if ($useragent == $useragents['noajax']) {echo 'ajax not supported!'} I didn't think it'd be that easy of course. What would be the best way to compare the $useragent to the $useragents['noajax'], and is there anything special I have to do to get this to work besides an includes? <?php $useragent = $_SERVER['HTTP_USER_AGENT']; $useragents = array ( 'noajax' => array // $useragents['noajax'] ( 'Opera/3', 'Opera 3', // Spoofing 'Opera/4', 'Opera 4', // Spoofing 'Opera/5', 'Opera 5', // Spoofing 'Opera/6', 'Opera 6', // Spoofing 'Opera/7', 'Opera 7', // Spoofing 'Opera/8.00', 'Opera 8.00', // Spoofing 'Opera/8.01', 'Opera 8.01', // Spoofing ), ) ); ?>
|