Change Included Code
Can I modify code that I have included using
<?php
include("../Index.php");
?>
The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Included PHP Code Not Parsed!?!
On a hired webserver, the php code that is in the files included with 'include_once' and 'include' command is not parsed. The php file which includes these parses just fine. The included php is also parsed just fine on my test apache. Example: Request 'www.myurl.com/page.php' on the browser, it runs correctly, including the file 'menubar.inc' into the outputted content. The file menubar.inc contains html and php, in the following manner: <img src="img/LogoV<? echo $tmp; ?>.png" border="0" /> On my test server that would be parse to, for example: <img src="img/LogoV4.png" border="0" /> Thus displaying an image. BUT, on the webmotel the html comes out without parsing, as: <img src="img/LogoV<? echo $tmp; ?>.png" border="0" /> :( ? I would ask the customer service, but I know it will take +10 days to get the answer.
Fopen And Filename As Array Element (code Included)
i have a piece of code that reads a csv list. For instance: 1,index.html 2,linux.html I read these in an array and then i want to use the filename (2nd array element) to make a file and write something in it. However, i always get the error: Warning: fopen(index.html ): failed to open stream: Invalid argument in E:DATAstartpagegenerate.php on line 34 Cannot open file The code that gives problems is this and more specificaly the titel var if (!$file_handle = fopen($titel,'a')) { echo "Cannot open file ".$titel; die; } If i for instance change this $titel to "index.html" then i do not get warnings. So it probably has to do with how $titel is presented. I tried wrapping $titel in double qoute, that doesn't work either. I tried wrapping $titel in single qoutes but that off course uses $titel as the name of the file instead of the content of the variable. How can i make this work? Code: ==== <?php $PAGES = "pages.txt"; $data = 'This ' $data .= 'is a ' $data .= 'string.' /* open pages parse them and make the pages */ $file = file($PAGES); foreach ($file as $line) { $arTemp = explode(",",$line); $aPages[$arTemp[0]] = $arTemp[1]; echo "Making ".$arTemp[1]." with id ".$arTemp[0]." "; unset($arTemp); } foreach ($aPages as $sleutel => $titel) { print "Huidige waarde van $aPages: $sleutel, $titel. "; /* write file*/ if (!$file_handle = fopen($titel,'a')) { echo "Cannot open file ".$titel; die; } if (!fwrite($file_handle, $data)) { echo "Cannot write to file ".$titel; die; } fclose($file_handle); } ?>
Old Code Vs New Code - Language Syntax Change?
I've recently begun programming PHP again and have found my old code doesn't work anymore. It's been a few years since my code was written, and simple functions don't seem to be working. I've done a bit of research into the syntax again and found the following; I used to use a function as such; if ($REQUEST_METHOD=="POST") { Now I've seen alot of the syntax is if ($_SERVER($REQUEST_METHOD=="POST")) { And referencing variables from the form is as such; $_POST['variable'] Where previously I could reference them in the simple form; $variable Has there been a language syntax change that would cause my old code to be obsolete? Is there a configuration line that could be changed to allow this old code to work?
Change Code From PHP 5 To PHP 4
i have copied code from a book that includes my_sqli which i have found that it is not compatible with the PHP 4 that my web hosts uses. Can any help make it compatible with PHP4? Code:
Problem With A File Included Twice When I Want It To Be Included Once
I have a problem with a file that apparently is being included twice when I want it to be included once. I searched all my files and couldn’t find a place in which I am not calling it with include_once("file_name") Is there a way to print or output in any way which file calls this file? It could be an included file that calls this file, so I need to know the file name, not the page name that calls this file.
Included File Not Included Every Time
I have some pages where I'm including a header for the document - beginning of the HTML, style sheet, javascript, logos etc. The problem is that sometimes it's being included and sometimes it isn't - and I'm talking even on the same page. The header file is in the same folder as the document I'm including it in, so I'm just using: PHP Code:
PHP Change Control Program For My Code - Recommendations?
Summary: I'm looking for a good open source, Windows Change control program. What are people using for there PHP projects? Is there a clear leader for this? Can programs like MS Visual SourceSafe be used with PHP projects? Full details: I was looking for a way to manage the changes to my PHP coding projects. I currently use Textpad and when I make a change to the code file I saved the old code as the same name with the current date. As you can imagine I have accumulated a big list of files with all different dates as my application has evolved. Therefore I was thinking there must be someway to manage it better and I read about Change control which can store details such as what changed were made to code at a particular time. So what opensource, easy to install and get going with, Change control programs are people using out there? If I didn't go open source, would sourcesafe be a good option for a php project?
Need To Change PHP Code To Include A New Table In MySQL
I need a little help on this PHP results back end script page. I have a database with 3,ooo,ooo files and with 3 tables. I also have a shell script that loges onto a .gov site, downloads the updated database, and overwrites/populates the MySQL tables with the updated data every day via cron. The query works fine, but I added a new table, and would like to display the data from the new table UNDER the original results. I will post the php code below, but here are a few things that may help. There are 2 search fields, 1 for callsign, and the other for zip codes. I am only concerned with the callsign query. Also, this code is formated to query all 3 of the original 3 tables and return the most updated data. The original 3 tables are named am, en, and hd. When a search query for callsign is being done, it gets all the data from the 3 tables, am, en, and hd. Then it displays the results. I would like the results from my newly added table, named hamwave_logs, to be displayed just under the original results. All 3 tables plus my new table have a field named callsign. Here is the code:
Why Is /php/php.exe/ Included In Url When Using $PHP_SELF?
For some reason when I run $PHP_SELF in a script the url it returns includes /php/php.exe/ between the root folder and the actual php file from which $PHP_SELF originated. how to get rid of this so it shows the normal directory structure?
Same Variables Used In 2 Included Files
I have 2 seperete files I am including into a script. They uses the same verriables however I want one to execute and then the other. will this be a problem?
Check If A File Has Been Included Before?
I want my scripts to be warning and error free. Is it possible to check is a file has already been included as part of a "require", "require_once" or "include" call in the script? I guess I could just include everything and turn warnings/errors off, but I'd prefer not to do that.
No Error In Included Files
The problem is pretty simple. If I include a file <? include 'libs.php' ?> and this file contains an error (a missing ;), my php installation does not tell me anything. I simply receive no output.
Included Variables Are All Blank.
This is the first part of myblog.php, which is the page you see in the browser. <?php require("/home/www/htdocs/master.php"); //functions are in here $u = "test"; //username $htitle = "Test blog!"; //for <title> //includes dbcon(); //connect to database blog($u); // START PAGE echo $welcomemessage;Functions are in master.php. It calls function dbcon, which logs me into MySQL and selects the database. It calls function blog: function blog($u) { //not using $u for anything yet. require($path."blog/vars.php"); require($path."blog/head.php"); }Vars defines stuff needed for the blog, Head is the header, with <html>, <head>, etc. $welcomemessage is defined in vars.php, but it doesn't show anything when I echo it in myblog.php. I went into vars.php and made it echo in there, and it worked, so it is defined correctly and the file is included, but for some reason the variable goes blank by the time I get back to myblog.php. It's the same with all the arrays I defined in there too.
Feed Included URL Into A Variable.
I need to access a page (CGI) on a different server. I can do this fine with an include and that will display all the info I need on the screen. The problem I face is that I actually need to parse through that info. When i try assigning it to a variable... $dogggg = include ("$SpecialString");...the variable is always "1". $specialString is the URL Clearly what I am doing is wrong but if someone can please point me in the right direction for what I need to do in order to get that output into a variable so that I can parse it, do what I need to with that info and then display it.
How To Change One Page To Change All?
i need to know how to create a page where i only have to change one thing on one page so it changes that text or image on every page of my site. in other words i want to be able to create a template, so if i do want to vchange something in the duture, i only have to change on page, instead of changing each individual page.
Running Php Included From A Mysql Database
I'd like to include php-code out of a mysql (or odbc) database on a php-page and run that code. Is that possible? I know howto include normal text(&html) from a database to a php-page. But I'd like to work with templates, therefore in need just a little bit php-code in my database. (and included on my pages).
Passing Arguments To Included Php Script
I am working on a server that does not allow PHP to be embedded into documents unless they are in the cgi-bin directory. This is annoying but I've been working around it with wrapper pages in other directories that contain only <!--include virtual="/cgi-bin/relevant_script.php" -->. One of my scripts is more difficult to work with because it is a collection of links, each of which points to the same script with different arguments. It is not acceptable to my boss to go to a URL like mysite.com/sub/script1.html (which just includes a script in cgi-bin) and have that link to mysite.com/cgi-bin/script2.php?arg1=blah . I want to have the script included in script1.html to link to another wrapper page that takes arguments (script2.html?arg1=blah) and have the included script take those arguments...
Retrieving Variables From Included File
I'm trying to use a variable created in a file I'm including from within a PHP script: include("http://www.domain.com/script.php"); echo $variable; // $variable still empty? The $variable is created inside script.php but is empty when I echo it from the calling script. Is it the way I'm including the script via http? I have to do this since it's on another server.
Establishing PHP Session ID In An Included File
Forgive me if this doesn't make too much sense but I've been working on this project all day and my brain is a bit fried. To make some of my code more readable I made a file (called urls.inc) which I include in my PHP scripts. This file contains functions to return a URL with the session id tagged on the end. I've now found out that the session id returned by the functions in urls.inc is not necessarily the current, and more importantly correct, session id. I need to know if there is a way to establish the current session id within the included file. For info, I've built the scripts so that the session id is passed from page to page to avoid using cookies (part of the challenge, it's a college project) so I need the urls.inc file to know which session id to pass back otherwise it all goes a bit squiffy. Here's urls.inc : <?php session_start(); function logoutURL() { return "logout.php?PHPSESSID=" . session_id(); } function adminURL() { return "admintools.php?PHPSESSID=" . session_id(); } function homeURL() { return "main.php?PHPSESSID=" . session_id(); } ?> These are called like this : echo "<h3 align="center"><a href="" . adminURL() . "" target="mainFrame">Administration Tools</a></h3>"; If it turns out that there's no way to do what I'm after then it's not big deal because I can change the URL line to : echo "<h3 align="center"><a href="admintools.php?PHPSESSID=" . session_id() . "" target="mainFrame">Administration Tools</a></h3>";
Stopping Execution Of An Included File?
I have a structure like this: Code: /index.php /dir_1/index.php /dir_2/index.php . . /dir_n/index.php In the topmost index.php file i have a switch statement selecting the current active directory (e.g. dir_2) and including the index.php file in that dir, if it exists. Is there any way I can stop the execution of the included file (/dir_2/index.php) without affecting the calling file (/index.php)?
Getting Cookie From HTTP_COOKIE_VARS In Included File
There's this thing about cookies that's bothered me and up until now I simply got around it. I can't do it anymore right now and I need to solve this problem, so I'm asking for some help. I have used the include() function to include a few PHP bars and modules in a main PHP page. I can get cookies with the HTTP_COOKIE_VARS or $_COOKIE globals in the main page, but not in the included ones. If I open the included PHP pages as standalones, I can get the cookies. I already had tons of problems with include(), I guess this is just another one. Can anyone tell me if it is supposed to be so (PHP manual says I can access the related global from anywhere) or if there's a way to fix this. The one thing I can't do is reading the cookies from the main page and passing them to the include, because that would mean changing code for the whole site.
Session Data In Included Files
How does a script access the variables in a session file? Scenario: <?-- this is the main script include("main.inc.php") $Username = $myname //myname is a variable in the session file $html = new html; //html class defined in main.inc.php sneds out headers and so on do lots of other php stuff $html -> send_footer() // found in main.inc.php and itself 'includes' footer.php ?> Now footer.php 'included' from within the function send_footer defined in main.inc.php and called by the primary script wants to access $myname, the session variable that stores my user name. i can't seem to get it at all. Has anyone any idea or am i being too vague here? Do I need to do something else at the beginning of footer.php that 'gets' the variable again from the session file? If so, how? The session ID is accessible to it cos I had it print it out to make sure, and the session file does definately hold a variable of the right name, I just can't return the data for some reason.
BOF In The Included File Shows Up In The Browser
I have an UTF-8 PHP file which generates HTML Then I cut the beginning of that file, pasted into another UTF-8 file ind included this second file into the first one. After that the whole page moved down about one libe leaving a gap at the top of the browser window. Viewing the resulting code of the first file via VIEW-Source, I and see a square inserted before the included file. This does not show if I open the included file with a Unicode supporting text editor. A non-unicode editos shows i>? at the beginning of the file which, I understand, is BOF. So the problem is that the browser sees the second BOF and displays it as a small square in a separate line
Included File Not Loading Completely
This is my first post to this list, so forgive me if this is very basic. I have a file: overview.php that is including another file dolan_header.php I have tested it on three servers...on two of them it works perfectly, and on the third (the client's server) the header file fails to load the first ~12 lines of code. A functioning version of the page is here: http://64.132.144.101/~somedom/dolan/overview.php And a malfunctioning version is here: http://dolanconcrete.com/staging/overview.php I have placed the two PHP files here if anybody should care to inspect them. http://64.132.144.101/~somedom/php/dolan_php_debug.zip
Passed Variables In Included Files
I'm looking for a guide on how variables are handled in included files. A pitfall I've run into is that if I define a variable, then include a file, the variable can be displayed on the included file. But if I try to call that same variables on the included page within a function, the variable is undefined. Example: PHP Code:
Calling Included Remote Functions
I have central.php, which consists of this: <?php function square($num) { return $num * $num; } ?> at outerdomain.com, I have test.php, which consists of this: <?php include "http://www.centraldomain.com/central.php"; echo square(4); // outputs ཌ'. ?> outerdomain.com/test.php = "Fatal error: Call to undefined function: square() in blah/blah/test.php on line 12" wha'appen'? I thought you could call included functions? Hmm... if I put central.php on the outerdomain.com, it works. No calling functions from files included remotely?
Require_once Fails If File Already Included
I am having a problem with multiple includes. A.php require_once on two files: B.php then C.php C.php require_once on B.php again Then I get a message: Warning: main(../../B.php): failed to open stream: No such file or directory in /home/jkennedy/public_html/foo/php/secure/common/A.php on line 1 Fatal error: main(): Failed opening required '../../B.php' (include_path='/home/jkennedy/public_html/foo/php/secure:/usr/share/php:/usr/share/php/Smarty-2.6.2/libs:/home/jkennedy/public_html/foo/_php/secure/PEAR') in /home/jkennedy/public_html/foo/php/secure/common/A.php on line 1 If I comment out the second require_once of B.php in C.php, the error goes away and I still get the variables defined in B.php, so I know it is being included. My question is why is it failing in the manner that it is doing? From what I could tell in the manual require_once was supposed to do nothing if it was already included. And why the "Failed opening", as if the file didn't exist? I am using PHP 4.3.4.
Open Link In Included Page
How to include Link that could open in same page rather than going to another page for example, if i include a file in home.php <? include("/index.php") ?> and I want to open up the LINKS in "index.php" in same home.php. example - open "/index.php?p=Hits" on same home.php page I know i could have FRAMES but i dont want to frames in my site
Printing The Line Number And Name Of Included File
Does anyone know how to echo the line number and included file name in php. I like to use development tags but sometimes I forget what included file they are in and what line they are on. I use a master variable to turn off all of the dev tags, but I would really like an easy way to automatically print the line number and file where the function is. This would be like if there was an error, but with out breaking the script and with out generating a nasty error.
Sending Queries & Variables Across Included Files
I'm working on a template parsing engine of sorts. Basically the way it works is, depending on how a variable is set, a file is included. The file is an entire page containing HTML and PHP, starting at the <html> tag. What I had planned on doing was writing a query for that specific type page. For instance, on "index.php" I have my connection script, and on "include.php" I have the while($row = mysql_fetch_array($query)) loop to actually display what results the query got. Problem 1: Unless I write the query into a variable on include.php, I get an error. The error states that the query isn't a valid MySQL resource, but I know for certain it is, because if I write the exact same query on the included page with the exact same connection script, it works fine. Problem 2: For files that are included off of the included page (for example, I have an include on include.php that links "homeslice.php" to the page), I have to use the full path (http://mysite.com/ect/homeslice.php) rather than just the site path, (/ect/homeslice.php). My question: Is there a trick to getting these things to work the way I want them to, and if so, could someone please let me in on it?
Variable Scope Of Files Included Within Functions
I have a function that selects a file to include, then includes is. The file is including within the function, like so: function include_file($file_name) { [lots of logic here to figure out the path...] require $file_name; return; } My problem is that the file gets included *within* the function, so all the code in the file inherits the function's scope. Any variables declared in the include file are not global -- they're local to that function. Is there any way around this? Is there anything I can put in the included file or in the function to make sure that variables declared within it are global? (I can't just reference the variables before the require, because I have no way of knowing what's in the include file.)
Getting An Included PHP Script To To Include A File In The Same Directory.
I am a little stumped at why when I try to include a file in same directory as the script being processed, it looks in the same directory as the script that included it to begin with. Is there any way I can get around this? Is there anyway to get the name and/or of the script being processed, rather than the name and/or path of the script that was first called?
Included Templates Have Trailing Unwanted Characters
I have a script that opens a template file, reads through the file line by line printing each line. If a line contains a certain string, then that line gets replaced with a second template file. Unfortunately, the second included file always contains extra, unwanted characters that change everytime I refresh the page. I couldn't find anything related in the FAQ, Code:
Original PHP Configure Included APXS, Not On My Machine
phpinfo() (4.2.2) shows that the configure flags included --with-apxs2=/usr/sbin/apxs There is no apxs program/file on my computer. httpd -l shows mod_so.c , so DSO is definitely compiled into the binary. Trying to upgrade PHP with the same configure flags gives the error "Sorry ..." can't find apxs ... and why should it? It's not there! :) So how could the current installation have configured successfully?
Confused About Scope Of Globals In Included Files
I'm having an issue where what should be global variables are not in scope and I'm confused as to why. In Case 1 the variables are not in scope for functions in File2 In Case 2 the varibales are in scope for access in File1's functions AFTER the include In Case 3 the varibales are in scope for functionsin File2 Why does case 1 not work but case 3 does? Does case 2 the proper method to use? CASE 1:.........
Check User/password On Included Pages
if i have itlike tihs: login.php checks the username and sets $_SESSION[] variables login to 1 username to username and password to password: then it takes you to main.php. all that one does is include navigation and all the content. if the link is clicked. it also checks if the user's logged in. what i am wondering is. all the pages that are to be included. is it ok not to check username/password on them and only check if the variable $inc exists. that variable is set on main.php, plus the include pages dont have session_start() on them. will that stop people from accessing them individually? they cant fake variables right?
MySQL Transactions Doesn't Work With Included Files?
I have a situation where I open a database connection in main script. Then I start a transaction, have some queries, include an another php file within some queries and then commiting queries in the main script. All queries in the main script gets committed but those in the included file doesn't. Why's that? Adding COMMIT query to the included file doesn't work either. Here are an test code which clears what I mean: the main file (test.php): <?PHP $db = mysql_connect ("localhost", "dbuser", "dbpass") or die ("Database connection error!"); mysql_select_db("databasename") or die ("Database selection error!"); mysql_query("START TRANSACTION", $db); mysql_query("INSERT INTO news VALUES (NOW(),'author','message from main script')", $db); include "test2.php"; mysql_query("COMMIT",$db); mysql_close($db); ?> and the included one (test2.php): <?PHP mysql_query("INSERT INTO news VALUES (NOW(),'author2','message from the included script')", $db); ?> So, this script runs fine, but there is just one row inserted to db (the one from the main script (test.php)). var_dump of $db in the included script tells as it should: resource(2) of type (mysql link) Tables are InnoDB type and START TRANSACTION and COMMIT both returns true (1). I also made some error handlers but those were not trapped either.
How Do You Access An Array In An Included/required Field?
I have a large array that would be messy to include in the file "main.php" itself and would prefer to include/require it. Say I have the following line in "main.php": require_once('/arr.php'); And the "arr.php" file looks something like this: <?php array(1)='ok1@Ok.com' array(2)='ok2@Ok.com' array(3)='ok3@Ok.com' array(4)='ok4@Ok.com' array(5)='ok5@Ok.com' array(6)='ok6@Ok.com' array(7)='ok7@Ok.com' array(8)='ok8@Ok.com' array(9)='ok9@Ok.com' array(10)='ok10@Ok.com' ?> Would I be able to reference the array AS IF I had declared the array in "main.php"?
Session Variables Do Not Persist Into Included Files
In my index.php file I set a session variable $_SESSION['product'] = "foo"; and then in my html part of index.php I include a file menu.php using require_once() which I use to build the menu tree. However, the session variable is not available to me inside that include file. It is available to me inside index.php because if I echo it I can see it. If I go to page2.php it is also there. Just not in the include file.
Files Not Being Included With Set_include_path() Or Ini_set('include_path')
I cannot seem to wrap my head around this peculiar problem. I have tried using both the function to set my include path, and then echo the get_included_files() and the files do not appear in the array. I can use require() or include() with no problems, but when I try to set the include path, the files do not seem to be included. Is there some weird quirck or gotcha to using this feature of PHP? I thought all you have to do is provide the directory and viola it should work. Any advice?
Reloading Page From PHP Script Included With Javascript
I have a page with a div which is filled with content from a PHP script via javascript and innerhtml. Sometimes, depending on the results of the PHP script, I want to to reload the entire page, not just the div . However if I put a PHP redirect in the script, it just loads the entire page into the div.....
Classes Uncallable From Files Included Inside Functions.
I'm modifying a copy of oscommerce to work with a template system I'm building. This template system basically just includes a list of files in the order they are specified in the database and sets their permissions etc. It includes the files through a function, which is limiting the included files from referencing objects/classes/anything. Code:
Database Connection Problem In Included File On Root Directory
I have a file called tophtml.php that connects to the database. It's in the root directory of the site. It works perfect in the root directory. But if I call it in a sub directory. (e.g. require("../tophtml.php") or require("C:websitesdogrealm ophtml.php")) I get errors saying it can't connect to the database.
Value Of Variable Shown As "Array" When From Included File
I have this statement to find the latest date that a row was inserted ________ $entry=mysql_query("SELECT contact FROM board ORDER BY contact DESC LIMIT 1")or die ("Query failed:<br>$entry<br>Error: " . mysql_error()); while($myrow=mysql_fetch_array($entry)){ if (ISSET($myrow['contact'])){ $latest = date("d M y", ($myrow['contact']+50400)); } } ________ This reports the value for $latest correctly if the statement is in the document. However when the statement is in an included file the reported value for $latest is ... Array Where am I going wrong?
BB Code - Escape A Bracket In BB Code?
Is there a way to escape a "bracket" in BB code? The beginning of a bbcode post I made starts with something in brackets [like this]. This causes a strange thing to happen to the remainder of my post. Removing the brackets makes my post normal. That shows me that I need to escape the brackets. However, a simple backslash does not seem to do the trick i.e. this [wont work] I am not the administrator of the bb forum, just a poster. So I need to know what to do on my end (as opposed to an adiministrator's power to reconfigure, etc.
How Can I Find Out Parent (including) File Of Included File?
How can i find out parent (including) file of included file? Lets imagine that we want to for example auto_prepend file to each file on our server that would write out the name of file its being executed. I know, i can use PHP_SELF but what if i want to write name of file which is already included? I have a web page and i want on it show its name even if it was included, but not the included page itself is showing name but auto_prepend file to each php file, its duty of this auto_prepend_file to write it out i dont want myself to echo it on each page? do you feel me?
|