Jump to content

Problem loading a file into simplehtmldom


eatc7402

Recommended Posts

I am a new simplehtmldom user. It is working and the php api loads, and I can parse

when I lod data from a string. But if I attemp yo load data from a file like this...

$html->file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt");

 

I receive the following error.

Fatal error: Call to undefined method simple_html_dom::file_get_html() in...

 

Hmmm. The function IS defined in the api.

 

I'm not sure where I'M going wrong here.

 

eac7402

Link to comment
Share on other sites

Ahhh yes.. an EQUAL sign... that fixed that error.. but NOW I  get this...

 

Warning: file_get_contents(C:\eaahmpg\eatc7402\www\stations\Sydney\code able_data.txt) [function.file-get-contents]: failed to open stream: Invalid argument in C:\eaahmpg\eatc7402\www\php\simplehtmldom\simple_html_dom.php on line 39

 

An argument? What does it need here.. if I give it an empty argument is complains also.

 

$html = file_get_html("C:\eaahmpg\eatc7402\www\stations\Sydney\code\table_data.txt", "");

 

eatc7402

 

Link to comment
Share on other sites

I altered my code and when I called the function WITHOUT a file path like this...

 

$html = file_get_html("table_data.txt");

 

it no longer complains about any missing arg.

 

So... what is the required arg if I want to  fully specify the path to the file??

 

eatc7402

Link to comment
Share on other sites

"\t" in PHP is the special tab-character. As your path is in double quotes this special meaning is preserved, which is noticable if you look at the file path shown within the error:

 

Warning: file_get_contents(C:\eaahmpg\eatc7402\www\stations\Sydney\code able_data.txt) [function.file-get-contents]: failed to open stream: Invalid argument in C:\eaahmpg\eatc7402\www\php\simplehtmldom\simple_html_dom.php on line 39

 

You can either use single quotes, in which "\t" will not be converted to a tab-character, or escape it with a second backslash.

Link to comment
Share on other sites

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.