PHP - Why Can't I Include A Full Url? (noob Problem...)
It's just a simple question...
<?php include ('beginning.txt'); ?> Why can't I include the whole url, eg. ... include ('http://www.mywebsite.com/random/beginning.txt') ... ? It just shows a blank page if I type in the whole url name. I would like to include the file beginning.txt into several pages that are under the folder random. And another question... does it matter if I use ' or ". Some php guides say I should use include ('beginning.txt') some say I should use include ("beginning.txt"). Similar TutorialsI am trying to include my full url on my site. example /index.php?page=demo
On my local server this bit of code worked fine.
$active = "$_SERVER[REQUEST_URI]";
however on my live server it returns blank, i think maybe due to the fact that its a windows server ?
php self works, but only returns index.php and not the full ?page=demo url
$active = ($_SERVER['PHP_SELF']);
does anyone know how i can work around this?
Thanks
Edited by cloudll, 04 December 2014 - 02:37 PM. hey you guys, I have a bunch of files on a server and I had to populate each one with this code: <?php include("https://www.domain.com/r/pagevisit.php"); ?> however, I'm getting an error, which I understand: QuoteWarning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0 in This gentleman on SO suggests that doing this is not the right way, and will always throw the error: https://stackoverflow.com/a/23285648 This site is getting quite large now, and I might just have to throw the content of all the files into a DB and pull it out when each page is requested. however, for now everything is just PHP files sitting on the server. so the question => is there anyway I can keep the include() code I currently have on each page, or does each file have to have it changed to the relative URI path? if I can keep it the way it is, where is the configs to change it? I might not even have access to it since this is shared hosting. thanks! Adam Edited February 18, 2020 by ajetrumpetYou: As a PHP expert, you find the prospect of building yet another brochure-ware website distressing; you want to get your hands dirty building an advanced, MVC based application in a fun and supportive environment where you will be constantly challenged, always learning and delivering a product used by millions of people every day.
Our company was founded and is managed by developers who wrote the original software the company was built upon; the technical team are the core of our business. As a member of that team, it will be you who decides upon the on-going development of our technical stack as well as the product itself. You will of course have complete control over your workstation.
Our stack:
Qualifications:
A passion for programming, solving problems and building software customers love.
Experience building web-based applications as distinct from brochure-ware websites.
An expert in OOP/MVC/ORM programming techniques and PHP (v5.3+) frameworks. We happen to use Symfony2 but any relevant experience is fine.
You can bend MySQL to your will.
Solid front-end development experience with XHTML, CSS, and Javascript. Our stack includes AngularJS, CoffeeScript, jQuery and LESS.
An appreciation for a beautiful GUI and excellent user experience.
Expectation of a fast moving, agile environment. We ship code to customers daily – we’d expect you contribute from day 1.
You can validate your skills for example with source code samples, a github profile, contributions to an open source project, developer blog, stackoverflow answers etc.
What you will do:
Design (with help) and develop new channels for our software. In particular we are looking at apps using twilio (for voice/sms), facebook and twitter as well as a web based screensharing tool.
Integrate our software into other 3rd party applications. This could both be via APIs (salesforce, jira, 37signals) or through digging directly into the source code (sugarCRM, xenforo etc).
Continue improve and refine our existing channels and product. We are never satisfied and always looking for that small improvement, refactor or redesign that can increase usability, speed and functionality for our customers.
Work on our backend systems including internal developer tools and deployment processes, our SaaS application stack or the tools we have to manage our business.
Work on our mobile apps, built using our API / HTML5 and PhoneGap
About us:
Our principle product is DeskPRO, the helpdesk software platform. We make it easy for organisations (companies – large and small, charities, public sector organisations) to communicate with their users via email, twitter, facebook, SMS, web forms, live chat (text and voice) as well as providing publishing self-help tools, sales management, co-working tools and community based question and answers. DeskPRO is a platform where customers install the helpdesk applications they need to manage their business.
We sell this software to a range of organisations including large companies (e.g. Tumblr, Xerox, T-mobile, Fujitsu, Valve Software and AT&T) universities and the public sector all the way through to small family businesses. We have a dual license model; selling licenses to software installed on our clients’ servers (we don’t encrypt the code – so your code will get read!) and offering a fully managed SaaS solution. Millions of people use our software every day and a lot of agents spend their whole working day using it constantly.
What we offer:
Competitive salary based upon experience.
Friendly work environment at the Innovation Warehouse in Farringdon: http://theiw.org/.
30" monitor and control over your workstation setup. No corporate bureaucracy here.
A mixture of autonomy over your role and real responsibilities to the team and business.
Varied work. The DeskPRO product is large with lots of modules and technologies.
Review our source code before even applying; just ask and we will add you to our github account. Never accept a job until you have seen the code you will be working with.
We plan to have a lot of fun on this journey – please bring a sense of humour.
Apply:
Please send your CV and either a link to your online profile, github account or some sample source code to: jobs@deskpro.com
Ok so heres the deal, my friend wrote this for me, hes currently unavailable and i messed it up a bit. http://pastebin.com/k937xDve < there is the code. all i did is add the Code: [Select] target="name" onclick="window.open('http://www.web-hosting-service.org/green-certified.php?greensite=.$domain.','name','height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no'); return false;" bit. and now i get the error Parse error: syntax error, unexpected T_STRING in seal-generator.php Hi gang, new to posting but I've read the forum on and off. I'm coding a small community and will have a lot of questions for you over time. The first one is about a search function. We'll have users of different nationalities and languages and you will be able to search, only I was thinking there could be a better way. They'll enter those posts through a dropdown list and when you search it you will use checkboxes. I just don't see the results I want when I pick the array for info. Like I have this right now as the form (which is sent to the php page itself as POST): Nationality: <br /> <input type="checkbox"" name="natBox[]" size="30" value="all"/> All<br /> <input type="checkbox"" name="natBox[]" size="30" value="weuro"/> W Europe<br /> <input type="checkbox"" name="natBox[]" size="30" value="eeuro"/> E Europe<br /> <input type="checkbox"" name="natBox[]" size="30" value="wafrica"/> W Africa<br /> And the thing I was doing was to check the boxes with if (isset) and then make the query longer and longer, butI figure there could be a smarter way. Like if I was going to enter 200 countries I can't really check for all can I? After the check (now deleted) it sets the query to this: $query = "SELECT * FROM user_criteria WHERE (age BETWEEN '$ageFr' AND '$ageTo') AND nationality='$nationality'"; ...and the part I don't have now is to pick the array natBox and add every value so @nationality becomes for instance weuro OR wafrica etc. Got a more elegant approach? Im having a scope problem when creating a library. This is the test file: Code: [Select] <?php include_once 'lib/lib_inventario.php'; session_start(); hacerFormulario('Memoria Ram'); ?> And this the library importer: Code: [Select] <?php $lib_usada = 'Inventario'; include_once 'registroglobal.php'; $reg = RegistroGlobal::GetInstance(); include 'errores.php'; include_once 'test.php'; include 'sesiones.php'; include 'bd.php'; include 'seguridad.php'; include 'usuarios.php'; include 'web_inventario.php'; $reg->setConf('Libreria usada', 'Basica'); ?> Well, i explain what the second code does. It imports a few modules that have function or object definitions in they. So the idea is that just importing the lib_whatever file you import all the functions you need, and also set some configuration settings. My problem with the first code is that it says that the function is undefined, when it sure exist in web_inventario file... I get this error when trying to include header.php and sidebar.php Code: [Select] hParse error: syntax error, unexpected '/' in /home/ucherllo/public_html/index.php on line 26 Here are is index.php and includes code. INDEX.PHP Code: [Select] <html> <head> <title>Cher LLoyd - UltimateCherLloyd.net - Your newest fan site for everything Cher Lloyd. News, media, photos, and more. </title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta name="description" content="Newest fan site for everything Cher Lloyd" /> <meta name="keywords" content="cher lloyd, cher lloyd fansite, cher lloyd x-factor, fansite, fan site, swagger jagger, playa boi, dub on the track, 2010, 2011, cher lloyd photos, cher lloyd news, cher lloyd media, cher lloyd fan site" /> <meta name="author" content="D" <meta name="robots" content="index, follow" /> <!-- PUT THIS TAG IN THE head SECTION --> <script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"> </script> <script type="text/javascript"> GS_googleAddAdSenseService("ca-pub-7892222271864999"); GS_googleEnableAllServices(); </script> <script type="text/javascript"> GA_googleAddSlot("ca-pub-7892222271864999", "FlauntDarkLeader"); </script> <script type="text/javascript"> GA_googleFetchAds(); </script> <!-- END OF TAG FOR head SECTION --> <link href="style.css" rel="stylesheet" type="text/css"> </head> <?PHP include(/home/ucherllo/public_html/header.php); ?> <td height="265" align="left" valign="top" bgcolor="#FFFFFF"> <?PHP $number=10; include("/home/ucherllo/public_html/news/show_news.php"); ?> </td> <?PHP include(/home/ucherllo/public_html/sidebar.php); ?> SIDEBAR.PHP Code: [Select] <td width="247" align="left" valign="top" bgcolor="#FFFFFF">testing</td> </tr> </table> <!-- End Save for Web Slices --> </body> </html> HEADER.PHP Code: [Select] <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="800" align="center" border="0" cellspacing="0" cellpadding="5"> <tr> <td bgcolor="#FFFFFF"><center><!-- PUT THIS TAG IN DESIRED LOCATION OF SLOT FlauntDarkLeader --> <script type="text/javascript"> GA_googleFillSlot("FlauntDarkLeader"); </script> <!-- END OF TAG FOR SLOT FlauntDarkLeader --></center></td> </tr> </table> <!-- Save for Web Slices (ucherlloyd.psd) --> <table width="801" height="359" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01"> <tr> <td colspan="11"> <img src="images/index_01.png" width="800" height="46" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="46" alt=""></td> </tr> <tr> <td colspan="7"> <img src="images/index_02.png" width="509" height="3" alt=""></td> <td rowspan="2"> <img src="images/index_03.gif" width="24" height="28" alt=""></td> <td colspan="3" rowspan="3"> <img src="images/index_04.png" width="267" height="179" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="3" alt=""></td> </tr> <tr> <td colspan="6" rowspan="3"> <img src="images/index_05.png" width="485" height="271" alt=""></td> <td> <img src="images/index_06.gif" width="24" height="25" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="25" alt=""></td> </tr> <tr> <td colspan="2" rowspan="4"> <img src="images/index_07.png" width="48" height="285" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="151" alt=""></td> </tr> <tr> <td rowspan="3"> <img src="images/index_08.png" width="13" height="134" alt=""></td> <td> <img src="images/index_09.gif" width="241" height="95" alt=""></td> <td rowspan="3"> <img src="images/index_10.png" width="13" height="134" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="95" alt=""></td> </tr> <tr> <td rowspan="2"> <img src="images/index_11.png" width="23" height="39" alt=""></td> <td><a href="index.php"><img src="images/index_12.gif" alt="" width="51" height="22" border="0"></a></td> <td> <img src="images/index_13.gif" width="88" height="22" alt=""></td> <td> <img src="images/index_14.gif" width="71" height="22" alt=""></td> <td> <img src="images/index_15.gif" width="93" height="22" alt=""></td> <td rowspan="2"> <img src="images/index_16.png" width="159" height="39" alt=""></td> <td rowspan="2"> <img src="images/index_17.png" width="241" height="39" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="22" alt=""></td> </tr> <tr> <td colspan="4"> <img src="images/index_18.png" width="303" height="17" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="17" alt=""></td> </tr> </table> <table width="799" border="0" align="center" cellspacing="0" cellpadding="5"> <tr> This is my website http://ucherlloyd.net/ PS: on Index.php there is also a Cutenews include that worked before i included sidebar.php & header.php HELP? Thanks in advance! Hi Ive only just started using PHP so go easy I have a PHP include for a menu on a site I run. <body> <html> <ul class="avmenu"> <li><a class="current" href="index.php">Home</a></li> <li><a href="about.php">About</a></li> <li><a href="services.php">Services</a></li> <li><a href="projects.php">Projects</a> <ul> <li><a href="highcroft_house.php">Highcroft House</a></li> <li><a href="barn_conversion.php">Barn Conversion</a></li> <li><a href="sunroom_extension.php">Sunroom Extension</a></li> <li><a href="dance_school.php">Dance School</a></li> </ul> </li> <li><a href="testimonials.php">Testimonials</a></li> <li><a href="offers.php">Special Offers</a></li> <li><a href="links.php">Links</a></li> <li><a href="contact.php">Contact</a></li> </ul> As you can see, on the first link, the index link, it has the class="current" property which displays a little tab next to the menu to show what link is currently selected. With using the include, obviously the class="current" is passed on to every page. Is there a way that I can tell the include file to change according to what page its on? Any help appreciated! Thanks Tom I have a code where i include file (on submit). if isset(... include "example.php"; This example.php contains a variable $message which i later print in original code. How do i prevent getting undefined variable errors? (before submit button is pressed) Thanks Ok. So I.m trying to learn the language. I have this program: Code: [Select] <?php require_once("fillarray.inc"); ?> <html> <head> <title>PHP Class Lesson 2 - AJ</title> </head> <body> <h1>The Circumference of a Circle</h1> <br> <table border="1"> <thead> <tr> Circle Number:</tr> <tr> Diamater</tr> <tr> Circumference</tr> <tr> radius</tr> <tr> Area</tr> </thead> <?php foreach($arr as $diameter){ echo ("<td>"); echo("<tr align=\"center\"> 1 </tr>"); echo ("<tr> $diamater </tr>"); $circumference = $diameter * M_PI; echo ("<tr> $circumference </tr>"); $radius = $diameter/2; echo ("<tr> $radius </tr>"); $area = pow($radius,2)*M_PI; echo ("<tr> $area </tr>"); echo ("</td>"); } ?> </table> </body> </html> and in fillarray.inc I have: Code: [Select] $totalnum = rand(0,25); $arr = array(); for($i=0;i<$totalnum;i++){ $arr[$i] = rand(1,100); } But when I run it, this is the display i get: Quote $totalnum = rand(0,25); $arr = array(); for($i=0;i<$totalnum;i++){ $arr[$i] = rand(1,100); } The Circumference of a Circle Circle Number: Diamater Circumference radius Area Any help on whats going on? i am running a file in the following folder on my hosting server /httpdocs/folder1/folder2/script.pjp how do i include a file that is located at the root of the hosting server /httpdocs/globalFunctions.php iv tried $maindir = dirname(__FILE__) . DIRECTORY_SEPARATOR; require $maindir . DIRECTORY_SEPARATOR . "globalFunctions.php"; include('http://www.domainname.com/globalFunctions.php'); and include('../../globalFunctions.php'); but none of these work any ideas I am simple using include to include a file within the webpage. include $file; $file does exist and is a string. This works fine locally but when testing on my live server it isnt included and nothing below the include is executed, not even plain html. The error log shows nothing, and there are no errors on screen even when using E_ALL. So i decided to make $file point to the file on the server to see if it was picking it up and it does. So why doesnt the live server want to include this file? The file consists of php and html but there arent any errors. It wouldnt work locally if there were. Any ideas? Haven't posted here for quite a while but I'm working on my first php driven website and am having a few problems with some includes that I'm sure you'll find to be fairly basic and obvious. What I'm trying to do is get my "home" page to load into a division when you initially visit my site. The header and footer had an include that contains various links which include this home page. The navigation links to the start page work perfectly and as expected, however when the site is visited initially all I get is a blank space in the main content division. The site in question is linked here... http://valvetech.byethost14.com/ The code that I'm using is as follows and I'm at a complete loss as to what I'm doing wrong. Code: [Select] <div id="center_column"> <?php $url = ''; if (!empty($_GET['category'])) { $url .= $_GET['category'] . '/'; } if (!empty($_GET['page'])) { $url .= $_GET['page'] . '.php'; } include $url; ?> </div> Thanks in advance for any assistance anybody can give me because I'm at the end of my rope on what should be a fairly easy problem to fix. -Carl Hi, I am trying to include my menu and header on my website. It seems to be picking up the pictures but not showing them. My code is: <?php include ("..\head.html"); ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td valign="top" align="left" width="90"> <?php include ("..\menu.html"); ?> My file structure is like this: FILE menu.php FILE head.php FOLDER blog - FILE index.php(where the code came from) FOLDER Images The menu and head files all link to the images folder, it is showing me the name of the image but just a little red cross. I hope that explains it ok. I don't knwo if i'm just missing something simple. Can anyone help? Hey guys! Well this is actually kind of a weird problem I have been having, and not too sure why I'm getting this problem. I've tried a lot of stuff, and it doesnt seem like I've been able to find a solution. I've been trying for about a month. Anyways, I have a website created with some OOP. Well, once I write an include statement to include a file, which then includes all my classes, it messes up my font, moves my website content down, and well.. it just does weird stuff. However, once I comment the include out, the website looks normal again. so basically, I can comment out the file itself and everything is just fine. But it only happens when I include my class files. Any ideas or suggestions would be amazing! Thank you! Hey there, I guess, theres something wrong with this page, 'cause it isnt loading the page I'm trying to include, please take a look: <? require "/backend/functions.php"; $con = mysql_connect('localhost', 'mdown', 'e5r8htt9'); mysql_select_db("actual", $con); dbconn(true); ?> <html> <body BGCOLOR="#000000"> [...] </style> <div class="wrapper"> <div class="rec"> <img src=test/recs.png border=0> </div> <div class="hormenu"> <img src=test/hormenu.png border=0> </div> <div class="cpanel"> <img src=test/cpanel.png border=0> </div> <div class="menu"> <img src=test/menu.png border=0> </div> <div class="baresq"> <img src=test/baresq.png border=0> </div> <div class="table"> <? include 'home/newtable.php'; ?> </div> <div class="bardir"> <img src=http://mdown.org/tretas/teste.V4/bardir.png border=0> </div> </div> </body> </html> Now the page with this code isnt showing anything inside the TABLE div and I guess it should display the content of newtable.php. The newtable.php is working perfectly and the is just the data selected from a table. Any idea about where did I messed up? thanks Hello, I have a simple issue with a code that uses includes. What I want to do is to include a bit of php code I made to my main pages so I don't have to edit each file that will contain the same included code. The problem with that included code is that contains variables that only the main files would know. Let me show you basically what I'm talking about. mainfile1.php Code: [Select] <?php $cat = "meow"; include "content.php"; ?> mainfile2.php Code: [Select] <?php $cat = "mew"; include "content.php"; ?> (mainfile3.php and so on...) content.php Code: [Select] echo '<center>My cat said '.$cat.' today!</center>'; I was expecting to see: My cat said meow today! and My cat said mew today! But when I loaded both pages it rendered like this: My cat said '.$cat.' today! HTML works properly but the variables are ignored and displayed as plain text. What I need to do so those variables don't get ignored? Thanks. Hello, I have a small and annoying problem. Imagine that I have a main folder on my FTP server which has index.php and I then have a php folder for all of my small scripts and an includes folder for misc files. So, for instance http://www.somedomain.com/index.php http://www.somedomain.com/php/somescript.php http://www.somedomain.com/includes/somefile.html Inside somescript.php, I need to use one of the files from the includes folder, like this for example: require('../includes/somefile.html'); This is all fine, but the problem is when I include the PHP file on my index.php page. Then I am telling PHP to go one step back to find the includes folder, but the problem is that it only needs to go one step back if it PHP script is not included on some page outside of the php folder. If I run php/somescript.php, there is no problem, but if I include php/somescript.php on my index.php, then there is trouble! I hope you guys understand what I mean. Thanks in advance! PS - I would appreciate if the solution is not about moving php/somescript.php or using full URLs in my includes. I use my desktop (Windows) to make websites and then once it's completed transfer to my Linux server but I've come across a weird issue. On Windows the file location is like this: C:\Server\Apache\htdocs\RSCEmulation On Linux the file location is like this: /home/rscemulation/public_html Now in those folders I have a folder called 'include', in that I have 2 files: header.php, functions.php In the base folder I have index.php. I then include header.php by using: include "include/header.php"; Then I include functions.php (from header.php) by using: include "functions.php"; Now on Linux this chucks an error, even with "./functions.php" -- I have to use include "include/functions.php" even though I'm already in that directory from the file I'm calling it from, although admittedly the file is being included from the directory below but this works fine on Windows with a base PHP install. This Linux box was given to me and I'm not sure if any PHP settings have been changed or not. I also have a config.php that I keep below the public directory (htdocs or public_html) but it won't let me include it on the Linux server by using "../../config.php" (I've tried all levels ranging from 0-5 with no luck) Can anyone shed some light on this please? I need it to work the same both on the Windows and Linux boxes as I copy and paste the files regularly and it's annoying changing them! Cheers. |