![]() |
Simple PHP Include Question... Help Please
in this file:
http://www.domain-one.com/folderone/...lename-one.php I want to use PHP to include a file located here: http://www.domain-two.com/folderone/...lename-two.php I can't seem to get it to work. I've been looking around for answers and there seems to be a few different ways to do it and I can't get any to work :( Help!? |
Quote:
|
I can't see the files,
but the file you read in should just be some functions, no < H T M L > or < ? p h p just like you copied and pasted it into the main file. include 'http://site.com/secondfile.php' should work! Do a test, copy the 2nd file into your main file - same error message? |
Quote:
If they are on the same server then include the file from domain 2 using the full path to the file, not the url. If they are not on the same server then if you are on win you cannot use include to pull it in, if you are on nix you can use include using the url if allow_url_include is set to true in your php.ini file. . |
Quote:
|
If allow_url_fopen is disabled on your server you won't be able to do it in php.
|
<?php
$curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://example.com/folder/file.html'); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1) ; $buffer = curl_exec($curl_handle); curl_close($curl_handle); echo $buffer; ?> |
Quote:
Quote:
|
at the very least post something. my suggestions both work.. what you have posted does not :)
|
Quote:
The relative path is less likely to break when you move servers. Quote:
allow_url_fopen requires stupid. Therefore include(url) requires being stupid. Use SmokeyTheBear's cURL code if they are on different servers. Be aware that's not like a PHP include, as you're getting the OUTPUT of the remote PHP script, not it's contents. Quote:
|
Quote:
|
Btw be very, very careful if there are any variables in the path or especially a URL. The bad guys can be very tricky about sneaking stuff into variables so you end up executing whatever they put at http://hacker.com/yourfucked.php?you.com/yourscript.php
Also you said "it doesn't work". What does the error log tell you about WHY it didn't work? When you say "it doesn't work", the second half of that sentence is the important part - it doesn't work and the error log says that's because ... The very important message in the error log assumes you don't prefix the statement with "@" as you sometimes see people do. "@" means "when this fails don't tell me why and don't stop processing, just keep going as pretending it worked, without telling me what's wrong". It could be useful if you know that the statement is SUPPOSED to fail sometimes. |
Quote:
Myself, unless I have control of the file I am pulling in, or it is on an extremely trusted site, I'm not pulling it in or pushing it out. If I had this issue, on 2 different servers, with domains I control, I would probably just duplicate the file from server 1 on server 2. If the file was dynamic then I would use a curl solution like Smokey's. but that just me. |
Quote:
Smokey can you help me with a script that uses $curl to send an XML request with POST? I need to read the XML stats and populate my Aff Program tables. |
Quote:
curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS,"var=whatever&var1=whatever&var 2=whatever); |
Quote:
|
Quote:
Since I've called allow_fopen_url "stupid", I should acknowledge that I've written stupid code. A lot of what I've learned I didn't learn from a book, but from doing stupid. Heck, most of what I write wouldn't make it into the kernel, Linus would call it stupid. So my comment is only that the function should be avoided and shouldn't be interpreted as a slam on PEOPLE who use it. |
Quote:
Thanks! I'm setting up the server today so I'll get what I can on there first so you can have a look. :thumbsup |
Know what I love about threads like this?
Guy comes in and asks a question. 4 different programmers and cam_girls come in and offer up solutions, reccomendations and what not and there is no trace of the original poster. Glad cam_girls got his hook up with smokey though. At least someone got something from the conversation. Makes ya wonder, ya know? . |
I bet none of the above solutions will work anyway because the OP probably wants to include the source file not the output file.
|
I want to thank everyone for their suggestions. I am going to keep playing with this today and try all the solutions. I know there are security concerns as well, which adds a bit to the mind fuck of what I thought was a simple thing.
|
Quote:
It works anyway. |
Quote:
Using php short tags can also cause problems when using xml directives. |
Quote:
|
Quote:
http://camaffiliate.com/chron_get_xml_2.php 400 Bad Request http://camaffiliate.com/chron_get_xml_2.txt Can you see the problem? :thumbsup |
All times are GMT -7. The time now is 04:54 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123