WordPress.org

Ready to get started?Download WordPress

Forums

PHP Code for posts
[resolved] Where are files saved? My php code creates a txt file using fopen. (3 posts)

  1. andyngae
    Member
    Posted 9 months ago #

    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/

  2. The.Missing.Code
    Member
    Plugin Author

    Posted 8 months ago #

    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

  3. siva6
    Member
    Posted 1 month ago #

    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?

Reply

You must log in to post.

About this Plugin

About this Topic

Tags