Page 1 of 1

Lost in arrays

Posted: Fri Aug 08, 2008 4:27 pm
by JB4
I've got a table that I want to insert a line of a text file into each spot of the table. The text file looks like this:

Code: Select all

<a href="#"><strong>Testing 1</strong></a>
<a href="#"><strong>Testing 2</strong></a>
<a href="#"><strong>Testing 3</strong></a>
<a href="#"><strong>Testing 4</strong></a>
<a href="#"><strong>Testing 5</strong></a>
<a href="#"><strong>Testing 6</strong></a>

Code: Select all

        <div id="rheadlines">
        <?php
            $rheadlines = @fopen(headlines.txt, 'r');
            $head = explode("\n", fread($rheadlines, filesize('headlines.txt'))); 
        ?>
            <table cellpadding="0" cellspacing="5">
                <tr>
                    <td>
                      <?php echo $head[0]; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                      <?php echo $head[1]; ?>
                    </td>
                </tr>               
                <tr>
                    <td>
                      <?php echo $head[2]; ?>
                    </td>
                </tr>               
                <tr>
                    <td>
                      <?php echo $head[3]; ?>
                    </td>
                </tr>               
                <tr>
                    <td>
                      <?php echo $head[4]; ?>
                    </td>
                </tr>                       
                <tr>
                    <td>
                      <?php echo $head[5]; ?>
                    </td>
                </tr>                               
            </table>
        </div>
I know I'm doing something wrong and suspect it's an easy fix, but I'm not sure what.

Thanks for any help!

Re: Lost in arrays

Posted: Fri Aug 08, 2008 6:41 pm
by nowaydown1
Not sure what the exact problem you are having is, but one thing I did notice is that your filename doesn't have quotes around it. You could always try to do something like:

Code: Select all

 
        <div id="rheadlines">
            <?php
            $rheadlines = fopen("headlines.txt", 'r');
            if($rheadlines) {
                while(!feof($rheadlines)) {
                    $head[] = fgets($rheadlines, 4096);
                }
                fclose($rheadlines);
            } else {
                die('Could not open headlines file for reading.');
            }
            ?>
            
            <table cellpadding="0" cellspacing="5">
                <?php foreach($head as $headline) { ?>
                    <tr>
                        <td>
                          <?php echo $headline; ?>
                        </td>
                    </tr>
                <?php } ?>                
            </table>
        </div>
 

Re: Lost in arrays

Posted: Sun Aug 10, 2008 5:36 pm
by JB4
The problem is that it's not actually writing anything in the table.

I tried what you said, and I don't get any errors, but It doesn't write anything.

Re: Lost in arrays

Posted: Sun Aug 10, 2008 11:41 pm
by califdon
JB4 wrote:The problem is that it's not actually writing anything in the table.

I tried what you said, and I don't get any errors, but It doesn't write anything.
The thing to do is determine what's being put into your $head array. Right after the line that is supposed to populate the $head array, put in this temporary debug line:

Code: Select all

 print_r($head);
and see what it shows.

Re: Lost in arrays

Posted: Tue Aug 12, 2008 9:11 pm
by JB4
ok so I fixed the code to look like this:

Code: Select all

       <div id="rheadlines">
            <?php
                            echo "testing1";
            $rheadlines = fopen("headlines.txt", 'r');
            if($rheadlines) {
                while(!feof($rheadlines)) {
                    $head[] = fgets($rheadlines, 4096);
                }
                fclose($rheadlines);
                echo "testing2";
                print_r($head);
            } else {
                die('Could not open headlines file for reading.');
            }
            ?>
           
            <table cellpadding="0" cellspacing="5">
                <?php foreach($head as $headline) { ?>
                    <tr>
                        <td>
                          <?php echo $headline; ?>
                        </td>
                    </tr>
                <?php } ?>                
            </table>
        </div>
and it doesn't echo testing1 or testing2... So now I'm realy confused.

Re: Lost in arrays

Posted: Tue Aug 12, 2008 10:03 pm
by califdon
That sounds like your PHP has a syntax error somewhere that prevents ANY of the PHP from being executed. I don't immediately see any errors in what you posted, but an error anywhere in the script could cause that. At the top of your script, turn on all the PHP error reporting:

Code: Select all

ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);

Re: Lost in arrays

Posted: Tue Aug 12, 2008 11:16 pm
by JB4
nothing changed... :x

so here is my whole code, it's just a template I got off of clan templates for free, so I don't know anything about it.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Band Of The Hand Alliance</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="all">
@import url("main.css");
</style>
</head>
<body>
<?php ini_set("display_errors","2");
 ERROR_REPORTING(E_ALL);
   ?>
<!-- 
Gunsmoke
A clantemplates template
Design by Bryan Le (Innate Media Group)
Coding by Viclei
Copyright 2005
 -->
<table id="container" cellpadding="0" cellspacing="0">
    <tr>
        <td rowspan="7">
            <img id="index_02" src="images/index_02.jpg" width="57" height="421" alt="" /></td>
        <td colspan="18">
            <img id="index_03" src="images/test_header.jpg" width="856" height="201" alt="" /></td>
        <td rowspan="6">            
        <img id="index_04" src="images/index_04.jpg" width="54" height="419" alt="" /></td>     
        <td>
            <img src="images/spacer.gif" width="1" height="201" alt="" /></td>
    </tr>
    <tr>
        <td colspan="2">
            <img id="index_06" src="images/index_06.jpg" width="161" height="34" alt="" /></td>
        
    <td> <a href="index.htm"><img src="images/index_07.jpg" alt="" width="49" height="34" border="0" /></a></td>
        
    <td> <a href="roster.htm"><img src="images/index_08.jpg" alt="" width="64" height="34" border="0" /></a></td>
        
    <td colspan="3"> <a href="matches.htm"><img src="images/index_09.jpg" alt="" width="74" height="34" border="0" /></a></td>
        
    <td> <a href="competition.htm"><img src="images/index_10.jpg" alt="" width="100" height="34" border="0" /></a></td>
        
    <td> <a href="forums.htm"><img src="images/index_11.jpg" alt="" width="75" height="34" border="0" /></a></td>
        
    <td colspan="5"> <a href="sponsors.htm"><img src="images/index_12.jpg" alt="" width="85" height="34" border="0" /></a></td>
        <td>
            <a href="#"><img src="images/index_13.jpg" width="88" height="34" alt="" /></a></td>
        <td colspan="3">
            <img id="index_14" src="images/index_14.jpg" width="160" height="34" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="34" alt="" /></td>
    </tr>
    <tr>
        <td colspan="18">
            <img id="index_15" src="images/index_15.jpg" width="856" height="6" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="6" alt="" /></td>
    </tr>
    <tr>
        <td colspan="18">
            <img id="index_16" src="images/index_16.jpg" width="856" height="24" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="24" alt="" /></td>
    </tr>   
    <tr>
        <td>
            <img id="index_17" src="images/index_17.jpg" width="38" height="121" alt="" /></td>
        <td colspan="4" id="trheadlines">
 
        <div id="rheadlines">
            <?php
                            echo "testing1";
            $rheadlines = fopen("headlines.txt", 'r');
            if($rheadlines) {
                while(!feof($rheadlines)) {
                    $head[] = fgets($rheadlines, 4096);
                }
                fclose($rheadlines);
                echo "testing2";
                print_r($head);
            } else {
                die('Could not open headlines file for reading.');
            }
            ?>
           
            <table cellpadding="0" cellspacing="5">
                <?php foreach($head as $headline) { ?>
                    <tr>
                        <td>
                          <?php echo $headline; ?>
                        </td>
                    </tr>
                <?php } ?>                
            </table>
        </div>
 
        <!--        <div id="rheadlines">
 
 
 
 
        <?php
         /*   $rheadlines = @fopen(headlines.txt, 'r');
            $head = explode("\n", fread($rheadlines, filesize('headlines.txt'))); 
        ?>
            <table cellpadding="0" cellspacing="5">
                <tr>
                    <td>
                      <?php echo $head[0]; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                      <?php echo $head[1]; ?>
                    </td>
                </tr>               
                <tr>
                    <td>
                      <?php echo $head[2]; ?>
                    </td>
                </tr>               
                <tr>
                    <td>
                      <?php echo $head[3]; ?>
                    </td>
                </tr>               
                <tr>
                    <td>
                      <?php echo $head[4]; ?>
                    </td>
                </tr>                       
                <tr>
                    <td>
                      <?php echo $head[5]; */ ?>
                    </td>
                </tr>                               
            </table>
        </div> -->
        <!--        <div id="rheadlines">
 
 
 
 
        <?php /*
            $rheadlines = @fopen(headlines.txt, 'r');
            $head = explode("\n", fread($rheadlines, filesize('headlines.txt'))); 
        ?>
            <table cellpadding="0" cellspacing="5">
                <tr>
                    <td>
                    DID IT WORK??<?php echo ; */?>
                     <a href="#"><strong>Bryan Le declared awesome designer!!
                    </td>
                </tr>
                <tr>
                    <td>
                    <a href="#"><strong>Brilliant coding by Viclei          
                    </td>
                </tr>               
                <tr>
                    <td>
                    <a href="#"><strong>Bryan Le declared awesome designer!!    
                    </td>
                </tr>               
                <tr>
                    <td>
                    <a href="#"><strong>Brilliant coding by Viclei          
                    </td>
                </tr>               
                <tr>
                    <td>
                    <a href="#"><strong>Bryan Le declared awesome designer!!    
                    </td>
                </tr>                       
                <tr>
                    <td>
                    <a href="#"><strong>Brilliant coding by Viclei          
                    </td>
                </tr>                               
            </table>
        </div> -->
      </td>
        <td>
            <img id="index_19" src="images/index_19.jpg" width="17" height="121" alt="" /></td>
        <td colspan="4" id="trmatches">
        <div id="rmatches">
            <table cellpadding="0" cellspacing="5">
                <tr>
                    <td>
                    <a href="#"><strong>Clan Templates</strong> Vs <strong>Everyone else</strong> </a>  
                    </td>
                </tr>
                <tr>
                    <td>
                      <a href="#"><strong>Clan Templates</strong> Vs <strong>Everyone else </td>
                </tr>               
                <tr>
                    <td>
                      <a href="#"><strong>Clan Templates</strong> Vs <strong>Everyone else </td>
                </tr>               
                <tr>
                    <td>
                      <a href="#"><strong>Clan Templates</strong> Vs <strong>Everyone else </td>
                </tr>               
                <tr>
                    <td>
                      <a href="#"><strong>Clan Templates</strong> Vs <strong>Everyone else </td>
                </tr>                       
                <tr>
                    <td>
                      <a href="#"><strong>Clan Templates</strong> Vs <strong>Everyone else </td>
                </tr>               
            </table>        
        </div>
      </td>
        <td>
            <img id="index_21" src="images/index_21.jpg" width="16" height="121" alt="" /></td>
        <td colspan="5" id="trthreads">
        <div id="rthreads">
            <table cellpadding="0" cellspacing="5">
                <tr>
                    <td>
                    <a href="#"><strong>Bryan Le declared awesome designer!!    
                    </td>
                </tr>
                <tr>
                    <td>
                    <a href="#"><strong>Brilliant coding by Viclei          
                    </td>
                </tr>               
                <tr>
                    <td>
                    <a href="#"><strong>Bryan Le declared awesome designer!!    
                    </td>
                </tr>               
                <tr>
                    <td>
                    <a href="#"><strong>Brilliant coding by Viclei          
                    </td>
                </tr>               
                <tr>
                    <td>
                    <a href="#"><strong>Bryan Le declared awesome designer!!    
                    </td>
                </tr>                               
                <tr>
                    <td>
                    <a href="#"><strong>Brilliant coding by Viclei          
                    </td>
                </tr>                               
            </table>        
        </div>
      </td>
        <td colspan="2">
            <img id="index_23" src="images/index_23.jpg" width="40" height="121" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="121" alt="" /></td>
    </tr>
    <tr>
        <td colspan="18">
            <img id="index_24" src="images/index_24.jpg" width="856" height="33" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="33" alt="" /></td>
    </tr>
    <tr>
        <td colspan="18" rowspan="2">
            <img id="index_25" src="images/index_25.jpg" width="856" height="5" alt="" /></td>
        <td rowspan="9" id="rborder">
      </td>
        <td>
            <img src="images/spacer.gif" width="1" height="2" alt="" /></td>
    </tr>
    <tr>
        <td rowspan="8" id="lborder">
      </td>
        <td>
            <img src="images/spacer.gif" width="1" height="3" alt="" /></td>
    </tr>
    <tr>
        <td colspan="12">
            <img id="index_28" src="images/index_28.jpg" width="586" height="21" alt="" /></td>
            <!-- !!!!!!!!!!!!!!!!!!-->
        <td width="270" colspan="6" rowspan="5" valign="top"><img id="index_29" src="images/index_29.jpg" width="270" height="21" alt="" /><!-- Start of main sponsor table --><table cellpadding="0" cellspacing="0">      
                <tr>
                    <td colspan="3"><img id="index_31" src="images/index_31.jpg" width="270" height="5" alt="" /></td>
                </tr>
                <tr>
                    <td rowspan="2"><img id="index_32" src="images/index_32.jpg" width="5" height="112" alt="" /></td>
                    <!-- Change this to your own image \/\/ -->
                    <td><a href="#"><img src="images/your_ad.jpg" alt="" width="260" height="107" /></a></td>
                    <td rowspan="2"><img id="index_34" src="images/index_34.jpg" width="5" height="112" alt="" /></td>
                </tr>
                <tr>
                    <td><img src="images/index_35.jpg" width="260" height="5" alt="" /></td>
                </tr>
          </table>
        <!-- End of main sponsor table -->
    <!-- Start of team supporters section -->
          <!-- Start of a team supporter -->
          <img id="index_36" src="images/index_36.jpg" width="270" height="21" alt="" /><table cellpadding="0" cellspacing="0">
                <tr>
                    <td colspan="3"><img src="images/ts_top.jpg" alt="" width="270" height="5" /></td>
                </tr>
                <tr>
                    <td><img src="images/ts_side.jpg" alt="" width="5" height="64" /></td>
                    <!-- Change this to your own image \/\/ -->
                    <td><a href="#"><img src="images/your_small_ad.jpg" alt="" width="260" height="64" /></a></td>
                    <td><img src="images/ts_side.jpg" alt="" width="5" height="64" /></td>
                </tr>
                <tr>
                    <td colspan="3"><img src="images/ts_bottom.jpg" alt="" width="270" height="6" /></td>
                </tr>
            </table>
          <!-- End of a supporter table -->
          <!-- Start of a team supporter -->
            <table cellpadding="0" cellspacing="0" style="padding:0; ">
                <tr>
                    <td colspan="3"><img src="images/ts_top.jpg" alt="" width="270" height="5" /></td>
                </tr>
                <tr>
                    <td><img src="images/ts_side.jpg" alt="" width="5" height="64" /></td>
                    <!-- Change this to your own image \/\/ -->
                    <td><a href="#"><img src="images/your_small_ad.jpg" alt="" width="260" height="64" /></a></td>
                    <td><img src="images/ts_side.jpg" alt="" width="5" height="64" /></td>
                </tr>
                <tr>
                    <td colspan="3"><img src="images/ts_bottom.jpg" alt="" width="270" height="6" /></td>
                </tr>
            </table>
          <!-- End of a supporter table -->
          <!-- Start of a team supporter -->
            <table cellpadding="0" cellspacing="0" style="padding:0; ">
                <tr>
                    <td colspan="3"><img src="images/ts_top.jpg" alt="" width="270" height="5" /></td>
                </tr>
                <tr>
                    <td><img src="images/ts_side.jpg" alt="" width="5" height="64" /></td>
                    <!-- Change this to your own image \/\/ -->
                    <td><a href="#"><img src="images/your_small_ad.jpg" alt="" width="260" height="64" /></a></td>
                    <td><img src="images/ts_side.jpg" alt="" width="5" height="64" /></td>
                </tr>
                <tr>
                    <td colspan="3"><img src="images/ts_bottom.jpg" alt="" width="270" height="6" /></td>
                </tr>
            </table>
          <!-- End of a supporter table -->     
          <!-- End of team supoorters section -->
      </td>
        <td>
            <img src="images/spacer.gif" width="1" height="21" alt="" /></td>
    </tr>
    <tr>
        <td colspan="12" rowspan="4" id="tcontent">
            <table cellpadding="0" cellspacing="0" id="contenttable">
                <tr>
                    <td>
                        <img src="images/content_top.jpg" alt="" />
                    </td>
                </tr>                   
                <tr>
                    <td>
        <!-- Edit the main content here -->             
                    
            <div id="content"> 
              <p>Main<br />
                You've just download "Gunsmoke" from <a href="http://www.clantemplates.com">Clan 
                Templates</a> designed by Bryan Le (Innate Media) and coded by 
                Viclei. It is a condition of usage that you leave a link back 
                to Clan Templates somewhere on the site. The" developed by" 
                text in the bottom right must not be tampered with including the 
                image and link. Thank you and enjoy. </p>
                      <p>------------------------<br />
                        There is a blank header in the "images" folder named "blank_header.jpg". Edit this and replace the existing header named "header.jpg". </p>
                      <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
         <a href="http://jigsaw.w3.org/css-validator/">
  <img style="border:0;width:88px;height:31px"
       src="http://jigsaw.w3.org/css-validator/images/vcss" 
       alt="Valid CSS!" />
 </a>
                      </p>                    
                      <p>
                      <strong> It is a long established fact</strong> - posted by <em>Viclei</em> - 27/9/2005<br />
                      It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
 
                      </p>
                      <p>
                      <strong> It is a long established fact</strong> - posted by <em>Viclei</em> - 27/9/2005<br />
                      It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
 
                      </p>
                      <p>
                      <strong> It is a long established fact</strong> - posted by <em>Viclei</em> - 27/9/2005<br />
                      It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
 
                      </p>                                        
                    </div>
        <!-- End of main content -->
                    </td>
                </tr>
                <tr>
                    <td>
                        <img src="images/content_bottom.jpg" alt="" id="contentbottom" width="586" height="8" />
                    </td>
                </tr>                   
            </table>
        </td>
    </tr>
    <tr>
      <td colspan="5" valign="top" height="5"></td>
    </tr>
    <tr>
        <td><img src="images/spacer.gif" width="1" height="21" alt="" /></td>
    </tr>
    <tr>
        <td>
      </td>
    </tr>
    <tr>
        <td colspan="18">
            <img src="images/index_38.jpg" alt="" width="856" height="52" border="0" usemap="#Map" id="index_38" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="52" alt="" /></td>
    </tr>
    <tr>
        <td colspan="18">
            <img id="index_39" src="images/index_39.jpg" width="856" height="29" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="29" alt="" /></td>
    </tr>
    <tr>
        <td>
            <img src="images/spacer.gif" width="57" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="38" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="123" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="49" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="64" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="11" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="17" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="46" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="100" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="75" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="28" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="16" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="19" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="5" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="17" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="88" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="120" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="35" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="5" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="54" height="1" alt="" /></td>
        <td>
            <img src="images/spacer.gif" width="1" height="1" alt="" /></td>
        <td></td>
    </tr>
</table>
<map name="Map" id="Map">
  <area shape="rect" coords="564,19,852,38" href="http://www.bryanle.refreshnetworks.com/v3/" onclick="window.open(this.href);return false;" alt="Portfolio of Bryan Le" />
</map>
</body>
</html>
 

Re: Lost in arrays

Posted: Wed Aug 13, 2008 12:09 am
by zeek
Try this:

Code: Select all

<div id="rheadlines">
<table cellpadding="0" cellspacing="5">
<?php
    // set the filename
    $filename = 'headlines.txt';
 
    // make sure that PHP can read the file
    if (!is_readable($filename))
    {
        die('Could not read file (' . $filename . ')');
    }
 
    // read the file into an array
    $lines = file($filename);
 
    // make sure that PHP can read the file
    if (empty($lines))
    {
        die('The file (' . $filename . ') is empty');
    }
 
    // for each line in the file
    foreach ($lines as $line)
    {
?>
    <tr>
        <td><?php echo $line; ?></td>
    </tr>
<?php
    }
?>
</table>
</div>

Re: Lost in arrays

Posted: Wed Aug 13, 2008 1:38 am
by JB4
I'm still not getting ANYTHING out.

Re: Lost in arrays

Posted: Wed Aug 13, 2008 12:55 pm
by califdon
OK, I copied your script and determined that the problem is in the code that opens the text file. If you comment out that entire If...else... block, the rest of the script seems to run and you get output. So what's wrong with the syntax, that makes PHP stop executing the script? See, if it just couldn't find the file, or something, then you would see an error message, but if PHP can't interpret the syntax, there's nothing it can do but just stop processing.

Since I don't see anything obviously wrong in your fopen() syntax, I would suspect the way you are specifying the filename. Here is the official reference to fopen() syntax and there are several notes that you should review, particularly as it relates to Windows, if you are running under Windows: http://us3.php.net/fopen.

But certainly that little piece of code is where the problem lies.