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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.