Jump to content

php mod with fopen inside Wordpress path issue


Murciano

Recommended Posts

HI,

 

Im having an issue with a small piece of custom php code inside WP, heres a brief explanation of what im doing and below is the code.

 

Im using a permalink structure of %category%/%postname%

 

Basically im using simplehtml dom to grab some stocks info and write it to a text file, which it does when i use this code:

 

 
include ('crawler_file.php');
$html = file_get_html("http://url that the info comes from/ticker=$Symbol:US");
$es = $html->find('div[class="detailsDataContainerLt"]');
$tickerdetails = ("$es[0]");
$CompDetails = "$Symbol.txt";
$FileHandle2 = fopen($CompDetails, 'w') or die("can't open file");
fwrite($FileHandle2, $tickerdetails);
fclose($FileHandle2);

 

however when i use that code above it gets the info ok but writes the file into WP root and not into the same folder from where called within the theme, strange thing is though the include file gets included no problem. I have tried absolute URL and also bloginfo each just throws out "or die" error of Cant Find File.

 

Its obviously a paths issue but im stuck as what to do next

thanks

 

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.