Jump to content

Recommended Posts

You are including a file from your own server, right?

 

Otherwise, the server you're trying to send the request to might have set header('Access-Control-Access-Origin: http://owndomain.com'); so that only their own domain can send HTTP requests to their site and get responses.

Just an educated guess, though.

Thanks for the quick response.

 

@Svenskunganka :     I tried to post my code but it doesn't allow me :(. As soon as I click save, it disappears :( . Let me try again.

@Irate: Yes I am trying to include a file on my sever itself.

 

1. Here is the dir structure:

a) /test/foo.php --> this has include to my own server. I tried to paste the exact code but it removed it :(. bascially its pointing to my own server using SERVER variables pointing to "bar.php"

b) /test/bar.php

 

2. Apache document root is pointing to "/test" like

=====

/var/www/html --> /test

=====

 

3. echo __DIR__  shows me "/test" so its definitely pointing to the right directory.

4. I have given full permssiion to this directory, in case that's the issue but no luck.

5. Exact error in apache error log. I had to remove the exact URL as this post doesn't allow me post that.

=====

[Mon Jul 08 10:41:49 2013] [error] [client ] PHP Warning:  include<URL>: failed to open stream: HTTP request failed!  in /test/foo.php

[Mon Jul 08 10:39:49 2013] [error] [client ] PHP Warning:  include(): Failed opening <URL> for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /test/foo.php

=====

 

Let me know if any other info is needed.

 

Thanks

Edited by samg

I assume you mean multiple includes in the same file.  If so, then two ways.  One is what you just described, but if you use a function you only need one include:

//foo.php
$a=1;
$b=2;
include('bar.php');

$a=3;
$b=4;
include('bar.php');

//bar.php
echo $a+$b;

Or using a function:

//foo.php
include('bar.php');
show_addition(1, 2);
show_addition(3, 4);

//bar.php
function show_addition($arg1, $arg2) {
   echo $arg1+$arg2;
}
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.