php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1101 File Writing problems (sorta)
Submitted: 1999-01-28 10:27 UTC Modified: 1999-06-20 20:27 UTC
From: plunneberg at netscape dot net Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.6 OS: Slackware
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: plunneberg at netscape dot net
New email:
PHP Version: OS:

 

 [1999-01-28 10:27 UTC] plunneberg at netscape dot net
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>";
//   ------------------------------------------------------------------------------------------------------------
//   ------------------------------------------------------------------------------------------------------------
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-20 20:27 UTC] jim at cvs dot php dot net
Haven't heard back.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 03:01:31 2024 UTC