0

5 and I am using a jumi component to run php file. some of the files were running perfectly but some are not specialy when im using require_once function. The errors are showing the following:

Warning: require_once( http://bphf2012.org/..._jumi&fileid=10 ) [function.require-once]: failed to open stream: No such file or directory in/home/content/13/10377813/html/components/com_jumi/views/application/view.html.php(40) : eval()'d code on line 21

Fatal error: require_once() [function.require]: Failed opening required ' http://bphf2012.org/..._jumi&fileid=10 ' (include_path='.:/usr/local/php5_3/lib/php') in/home/content/13/10377813/html/components/com_jumi/views/application/view.html.php(40) : eval()'d code on line 21

How to fix the problem?

Community
  • 1
  • 1
user1946440
  • 349
  • 1
  • 5
  • 13

2 Answers2

0

The require_once method you are using is not for external URLS. There is a distinction between local files and external files. You are trying to require a external file. For an external file (in this case a webpage) you could use curl (http://php.net/manual/en/book.curl.php) or file_get_contents (http://php.net/manual/en/function.file-get-contents.php)

if the file is on your local disk, require+once the filepath on your disk to it.

require('/home/content/13/10377813/html/components/com_jumi/views/application/view.html.php')

Vince V.
  • 3,115
  • 3
  • 30
  • 45
  • Actually the file is not on my local disk. It is on the jumi component and what im trying is locating like this : http://bphf2012.org/index.php?option=com_jumi&fileid=1. Could you please tell me how to use file get contents because i have tried it before but it is not working... You can check my files in the following url: https://www.dropbox.com/sh/vof0p4heo4csdn9/dj2NfgcWuE and the file where it starts running from is link. Thanks. – user1946440 Feb 06 '13 at 09:09
  • I can't access dropbox from here. But can you access your php.ini file ? – Vince V. Feb 06 '13 at 09:13
  • A short example btw: – Vince V. Feb 06 '13 at 09:20
  • The out put comes the same with the errors on my question. However, when I have changed the require_once to eval(file_get_contents('your url')); the page displays with an error on the top like: Warning: file_get_contents(http://bphf2012.org/index.php?option=com_jumi&fileid=10) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /home/content/13/10377813/html/components/com_jumi/views/application/view.html.php(40) : eval()'d code on line 21 – user1946440 Feb 06 '13 at 09:24
  • it means the page is unavailable. Or you need to provide some headers. Check the php documentation.:) – Vince V. Feb 06 '13 at 09:25
0

If you really want to include remote files, set allow_url_include to On.

Read more here - including a remote file in PHP

Community
  • 1
  • 1
Donatas Olsevičius
  • 1,350
  • 8
  • 13
  • do u mean using it instead of require_once file?? – user1946440 Feb 06 '13 at 09:10
  • Yes, instead of require_once. – Donatas Olsevičius Feb 06 '13 at 09:15
  • Now the file appears with the following error on the top: Warning: file_get_contents(http://bphf2012.org/index.php?option=com_jumi&fileid=10) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /home/content/13/10377813/html/components/com_jumi/views/application/view.html.php(40) : eval()'d code on line 21. Do I have to change any code on view.html.php file? – user1946440 Feb 06 '13 at 09:21
  • The problem is elsewhere - this url does not respond with any data. Even its headers say "HTTP/1.1 500 View not found [name, type, prefix]: jumi, html, jumiView" – Donatas Olsevičius Feb 06 '13 at 09:25
  • but like as the same url, I am running other files and they are working perfectly.. in this case, the only difference is just with the require_once or file_get_contents.... What shall I do now?? – user1946440 Feb 06 '13 at 09:28
  • Well, that means there's something wrong with this particular file and not in require_once or file_get_contents stuff. – Donatas Olsevičius Feb 06 '13 at 09:30
  • Could you please have a look on my php files from the following: https://www.dropbox.com/sh/vof0p4heo4csdn9/dj2NfgcWuE The file I am running from is link.php.. – user1946440 Feb 06 '13 at 09:32
  • As I wrote before, there's everything OK with this code. The problem is in http://bphf2012.org. Just go to http://bphf2012.org/index.php?option=com_jumi&fileid=10 using your browser and you'll see there's nothing in there. – Donatas Olsevičius Feb 06 '13 at 09:36