Bug #1101: File Writing problems (sorta)
| From: | plunneberg at netscape dot net | Date: | Thu, 28 Jan 1999 15:27:54 +0000 |
| Subject: | Bug #1101: File Writing problems (sorta) | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3763@lists.php.net to get a copy of this message | ||
From: plunneberg@netscape.net
Operating system: Slackware
PHP version: 3.0.6
PHP Bug Type: Parser error
Bug description: File Writing problems (sorta)
Ok... I've been working on a personal project for a news update page for my website. Something
simple that accepts the users name and a bunch of text and then writes it to the file in the
following order.
Name
Date
Time
Text .... blah blah blah
well... my problem exists when writing to the file. In the following section of code I write the
variables both to the screen and to the file. There have been two problems. When the file mode is
opened with "w" the code fails to write the "$fulln" and "$stuffs" to
the file, but succeeds in displaying it on the page. Second. When changing the mode to
"a", it succeeds in both writing to the file and the page, but also adds an extra blank
line and the date and time variables to the end of the file after the text.
I'm not sure what the problem could be here. Any help and I would be thankfull. Below the
following snippet of code is the entire code.
-----------------------------------
$updatedate = date( "Ymd" );
$updatetime = date( "His" );
$newsname = "./$phpnewsfolder/$updatedate$updatetime.txt";
$updatedate = date( "M dS, Y" );
$updatetime = date( "h:ia" );
$fullstringnews = "$fulln\n$updatedate\n$updatetime\n$stuffs\n";
echo "<P>01. Opening $newsname<P>".
"02. String = $fullstringnews<P>";
$f4 = fopen("$newsname","w");
fputs($f4, "$fullstringnews");
fclose($f4);
--------------------------------------------------------
full code below
<?php
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
// PHPNewsUpdateProcessor
$version = "1.1";
// Created by Paul A Lunneberg
// Started: Jan 26, 1999
// Finished: ??? ??, 1999
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
// Set up Default Variables
$phpnewsfolder = "phpnews"; // This is the directory that you will be keeping the news
files in.
// --------------------------------------------------------------------------
$brandingheader = "";
// include the full url of a header html file for branding the top of the pages
// --------------------------------------------------------------------------
$brandingfooter = "";
// include the full url of a footer html file for branding the bottom of the pages
// --------------------------------------------------------------------------
$htmlbgcolor = "#000000"; // #ffffff = White - you can change the html background
color here or the image next variable
$htmlbackground = "#000000"; // This could be an image also (use full url
Http://blahblah/blah.jpg)
$htmlbgcolor2 = "#000000"; // #cccccc = Light Gray - This is the table bacground
color.. its either static or random rotation or 4 pre chosen colors
$htmltextcolor = "#FFFF00"; // This is the main text color to be used throughout the
page
$htmltextcolor2 = "#ffffff"; // This is the highlight color for the name, date and
time information
$htmlmaintablewidth = 500; // 500 is plenty and also ensures that 640x480 users can view it.
$htmlmaintableborder = 0; // 0=no border, put any size in pixel value here.
$centeritall = 1; // 1=yes - 0=no Center main table?
$newstitle = "Pablosbrain News Update Processor!!"; // The title that will appear both
in the header and on the top of the page if an image is not specified as below
$newstitleimg = "http://www.mcrest.edu/plunneberg/images/pablosbrainnews.jpg";
$newstitle2 = "Processor!";
$order = 1; // 1=a to z - 0=z to a
$hrsize = 1;
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
// Start HTML Document
if($centeritall != 0)
{
$centerit = "<center>\n";
}
else
{
$centerit = "";
}
echo "<html><title>$newstitle - PHPNewsUpdate V$version</title>\n".
"<body bgcolor=\"$htmlbgcolor\" background=\"$htmlbackground\"
text=\"$htmltextcolor\">".
"$centerit\n".
"<table width=\"$htmlmaintablewidth\"
border=\"$htmlmaintableborder\"><tr><td><!--VirtualAvenueBanner-->\n";
if($brandingheader != "")
{
include("$brandingheader");
}
if($newstitleimg != "")
{
$newstitle = "<img src=\"$newstitleimg\" border=0
align=middle><br>$newstitle2";
}
echo "<center><b><font
size=+2>$newstitle</font></b></center>\n";
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
$updatedate = date( "Ymd" );
$updatetime = date( "His" );
$newsname = "./$phpnewsfolder/$updatedate$updatetime.txt";
$updatedate = date( "M dS, Y" );
$updatetime = date( "h:ia" );
$fullstringnews = "$fulln\n$updatedate\n$updatetime\n$stuffs\n";
echo "<P>01. Opening $newsname<P>".
"02. String = $fullstringnews<P>";
$f4 = fopen("$newsname","a");
fputs($f4, "$fullstringnews");
fclose($f4);
echo "<center><a href=\"./phpnews.php3\">check
it</a></center>\n".
"<script>\nwindow.setTimeout('window.location.href=\"./phpnews.php3\";',30000);\n</script>\n";
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
// end html document
if($brandingfooter != "")
{
include("$brandingfooter");
}
echo "</td></tr></table>\n".
"</body></html>";
//
------------------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------------------
?>
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net