Jump to content

Archived

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

Kronos9326

Write output of Database Query to file

Recommended Posts

[code]<table width="100%" border="0" cellpadding="0" cellspacing="0" class="BodyText">
        <?php do { ?>
          <tr>
                <td class="SmallText"><font color="#999999">RELEASED:</font> <a href="<?php echo $row_new['homepage']; ?>"><?php echo $row_new['name']; ?></a></td>
          </tr>
          <?php } while ($row_new = mysql_fetch_assoc($new)); ?>
      </table>[/code]

I've got the above script/query (and several others like it) that I would like to run every 20 minutes and write the contents to a text file. I would then include that file in various parts of the website. I am doing this to reduce the 'strain' of our DB server, since we've already run into problems with us running out of available connections.

Our server is running PHP version 4.3.11.

Can anyone help me with a simple PHP script that would do what I'm looking for. From there I'd apply to to the other queries I have running.

Any help would be appreciated.

David.

Share this post


Link to post
Share on other sites
Read reply below... Theres some code in these forums added by phpfreaks which is blocking the code needed :x

Share this post


Link to post
Share on other sites
[!--quoteo(post=362112:date=Apr 5 2006, 10:15 PM:name=DrDre)--][div class=\'quotetop\']QUOTE(DrDre @ Apr 5 2006, 10:15 PM) [snapback]362112[/snapback][/div][div class=\'quotemain\'][!--quotec--]
hmm? 403 Forbidden on post
[/quote]

I don't understand.. what's this got to do with my question?

David.

Share this post


Link to post
Share on other sites
[code]<?
//mysql stuff to get $new
ob_start();
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="BodyText">
        <?php do { ?>
          <tr>
                <td class="SmallText"><font color="#999999">RELEASED:</font> <a href="<?php echo $row_new['homepage']; ?>"><?php echo $row_new['name']; ?></a></td>
          </tr>
          <?php } while ($row_new = mysql_fetch_assoc($new)); ?>
      </table>
<?
$content = ob_get_contents();
ob_end_clean();
$f=fo pen('myfile.txt','a');
fwr ite($f,$content);
fcl ose($f);
?>
[/code]
Save to a php file, then look into Cron Jobs (google it if you need to)
And setup a cron job to run php /path/to/file.php (and some other parameter i cant remember) every 20 min

Wow... odd..


the staff here has some special code that throws 403 forbidden if you try to type code that accesses files...

namely the fw rite code

remove the spaces from the file writing functions.




testing


fputs();

Share this post


Link to post
Share on other sites

×

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.