Support » Plugins and Hacks » PHP Code for posts » Where are files saved? My php code creates a txt file using fopen.

  • Resolved andyngae

    (@andyngae)


    Hi,

    The plug-in works fine except I can’t find the file created by the code. The php code goes like this:

    <?php
    //stock quote script
    //this is the url for Stantec’s stock quote , we are opening it for reading
    $fp = fopen (“http://finance.yahoo.com/d/quotes.csv?s=STN.TO&f=sl1d1t1c1ohgv&e=.csv”,”r”);
    //this uses the fgetcsv function to store the quote info in the array $data
    $data = fgetcsv ($fp, 1000, “,”);

    $fp2 = fopen(‘data.txt’, ‘a’);
    fwrite($fp2, print_r($data, TRUE).PHP_EOL);

    ?>

    <!– this is our table which displays the stock info –>
    <!– we access the individual items by using $data[0]–>

    <table>
    <tr><td>Description</td><td>Latest figure</td><tr>
    <tr><td>symbol</td><td><?php echo $data[0] ?></td></tr>
    <tr><td>last price</td><td><?php echo $data[1] ?></td></tr>
    <tr><td>date</td><td><?php echo $data[2] ?></td></tr>
    <tr><td>time</td><td><?php echo $data[3] ?></td></tr>
    <tr><td>change</td><td><?php echo $data[4] ?></td></tr>
    <tr><td>open</td><td><?php echo $data[5] ?></td></tr>
    <tr><td>high</td><td><?php echo $data[6] ?></td></tr>
    <tr><td>low</td><td><?php echo $data[7] ?></td></tr>
    <tr><td>volume</td><td><?php echo $data[8] ?></td></tr>
    </table>

    <?php
    //close the filehandle $fp
    fclose ($fp);
    ?>

    Where do I find the data file?

    http://wordpress.org/plugins/php-code-for-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jamie

    (@themissingcode)


    Hi andyngae,

    you should probably specify an absolute path for saving your file so you know exactly where it saves. try looking in the plugin’s folder to see if it has saved there though.

    Thanks, TMC

    i am having a site tekheez.biz . i want to add external html and php code for my website’s content. where to save the code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Where are files saved? My php code creates a txt file using fopen.’ is closed to new replies.