Reputation: 43
I want to fetch div element from other website .
on which iam having my profile, i have tried using this code.
require_once('../simple_html_dom.php');
$html=file_get_html('http://www.example.com');
$ret=$html->find("div[id=frame-gallery]");
$ret=array_shift($ret);
echo($ret);
but this code is giving errors
Warning: require_once(../simple_html_dom.php) [function.require-once]: failed to open stream: No such file or directory in E:\wamp\www\in.com\components\com_content\view.php on line 22
Fatal error: require_once() [function.require]: Failed opening required '../simple_html_dom.php' (include_path='.;./includes;./pear') in E:\wamp\www\in.com\components\com_content\view.php on line 22
iam stuck with this plz help me with the code snippets for fetching the specific div element from a website
Upvotes: 2
Views: 2081
Reputation: 50720
The file simple_html_dom.php
is not where you're telling PHP to look for it.
require_once('../simple_html_dom.php');
To be safe, try using the full path instead of a relative path.
require_once('E:\wamp\www\in.com\components\simple_html_dom.php');
BTW, if the full path above is incorrect, then that is your problem. This is the path that PHP is trying.
To clarify: I'm only suggesting the OP switch to absolute paths to identify and confirm the source of the issue. Going to production with absolute paths is rarely a good idea.
Upvotes: 4
Reputation: 4235
Your inlude_path should contain ".", which means current directory.
But if you having troubles with including file by relative name, then just try to use absolute names, like require_once('E:\wamp\www\in.com\components\simple_html_dom.php');
But better it should be:
require_once 'E:/wamp/www/in.com/components/simple_html_dom.php';
Upvotes: 0
Reputation: 196
require and include paths can be tricky in PHP. Try to use full paths when you can. You'll find $_SERVER['DOCUMENT_ROOT'] usefull for that.
Upvotes: 1