php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16225 fwrite/fputs writes everthing twice with 'a' mode
Submitted: 2002-03-22 16:49 UTC Modified: 2002-03-22 17:10 UTC
From: speltzer at unisolutions dot de Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.1.2 OS: SuSe Linux 7.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: speltzer at unisolutions dot de
New email:
PHP Version: OS:

 

 [2002-03-22 16:49 UTC] speltzer at unisolutions dot de
if fopen opened a file with a or a++ fwrite writes everthing twice into the output file.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-22 17:10 UTC] sander@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

 [2003-01-28 03:02 UTC] hematec at gmx dot de
I had the same problem under win xp and apache 2.0.44 with php4:

fwrite writes sometimes strings twice in the file:

my sourcecode is:

$artikel_nr;
$kundennummer;
$artikel_anzahl;
$bemerkung;
if (($artikel_nr!='') and ($artikel_anzahl>0))
{
//?berpr?fen ob heutiger wk existiert, sonst anlegen!!
	$datum=date('d-m-y');
	$datei_name=$datum.".wk";
	$datei_pfad="wk/".$kundennummer."/";
	$datei=$datei_pfad.$datei_name;
//Datei ?ffnen
/*$tmp_string='';
if(file_exists($datei)){
	$file_handler=fopen($datei, 'r');
	do {
	$tmp_string=$tmp_string.fgets($file_handler, 500)."\n";
	} while (!feof($file_handler));
	fclose($file_handler);
	}*/

$file_handler=fopen($datei,a);
//artikel-string erzeugen und in datei schreiben
	$artikel_string=$artikel_nr."|".$artikel_anzahl."|".$bemerkung."\n";
//in Datei schreiben	
	fwrite($file_handler,$artikel_string);
//datei schlie?en
	fclose($file_handler);
}
?>
<html>

<head>
<script language=JavaScript>
		

	function neu_sortieren(kriterium){
		parent.ergebniss.document.search_parameter.sortierung.value=''+kriterium;
		parent.ergebniss.document.search_parameter.submit();
		}


	function artikel_in_korb(){
		var fehler=0;
		//artikeldaten holen
		var artikel_nr='';
		document.bestellen.artikel_nr.value=top.details.artikel_details.artikelnr.value;
		var kundennummer='';
		document.bestellen.kundennummer.value=top.oben.kundendaten.kundennummer.value;
		var session_nr='';
		document.bestellen.session_nr.value=top.oben.kundendaten.session_nr.value;
		
		//bestellmenge ?berpr?fen
		var tmp=document.bestellen.artikel_anzahl.value;
		tmp=parseInt(tmp);
		if (isNaN(tmp)){
			fehler=2;alert('fehler 2');}
		else{
		document.bestellen.artikel_anzahl.value=tmp;}		

		//artikeldaten ?berpr?fen
		if (document.bestellen.artikel_nr.value==''){fehler=1;}
		
		if (fehler==0){
		document.bestellen.action="bestellen.php"
		document.bestellen.submit();
		}
		else
		{document.bestellen.artikel_nr.value='';
		document.bestellen.artikel_anzahl.value=0;
		if (fehler==1){
			alert('Sie haben kein Artikel markiert!');
			}
		if (fehler==2){
			alert('Die Bestellmenge ist nicht ganzzahlig!');
			}
		}
	}

</script>
<title>markierte Artikel in Warenkorb legen</title>
</head>

<body bgcolor="#6666FF">

<form name='bestellen' method='post'>
<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" id="AutoNumber1">
    <tr>
      <td width="55">&nbsp;</td>
      <td width="75">
      <p align="right"><font face="Arial" size="1" color="#FFFFFF">Anzahl</font></td>
      <td width="50">
      <input type="text" size="4" name="artikel_anzahl" value="1">&nbsp; </td>
      <td width="60">
      <font size="1" face="Arial" color="#FFFFFF">Bemerkung</font></td>
      <td width="200">
      <input type="text" name="bemerkung" size="30"></td>
      <td width="195">
      &nbsp;<input type="submit" value="Artikel in Korb" onclick='javascript:artikel_in_korb();'></td>
      <td width="125">&nbsp;</td>
    </tr>
  </table>


  </center>
</div>
<input type=hidden name=artikel_nr>
<input type=hidden name=kundennummer>
<input type=hidden name=session_nr>
</form><!-- bestellen -->
  <div align="center">
    <center>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-right-width:0; border-top-width:0; border-bottom-width:0" bordercolor="#000000" width="772" id="AutoNumber2" bgcolor="#9999FF">
    <tr>
      <td width="70" align="center" style="border-top-color: #000000; border-top-width: 1; border-bottom-color: #000000; border-bottom-width: 1">
      <b><a href="JavaScript:neu_sortieren('artikelnr');"><font size="2" face="Arial" color="#ffffff">Artikelnr.</font></a></b></td>
      <td width="90" align="center" style="border-top-color: #000000; border-top-width: 1; border-bottom-color: #000000; border-bottom-width: 1">
      <b><a href="JavaScript:neu_sortieren('herstnr');"><font size="2" face="Arial" color="#ffffff">Herstellernr.</font></b></a></td>
      <td width="410" align="center" style="border-top-color: #000000; border-top-width: 1; border-bottom-color: #000000; border-bottom-width: 1">
      <b><a href="JavaScript:neu_sortieren('bezeichnung');"><font size="2" face="Arial" color="#ffffff">Bezeichnung</font></b></a></td>
      <td width="70" align="center" style="border-top-color: #000000; border-top-width: 1; border-bottom-color: #000000; border-bottom-width: 1">
      <b><a href="JavaScript:neu_sortieren('preis');"><font size="2" face="Arial" color="#ffffff">Preis</font></b></a></td>
      <td width="110" align="center" style="border-top-color: #000000; border-top-width: 1; border-bottom-color: #000000; border-bottom-width: 1">&nbsp;</td>
      <td width="16" align="center" bgcolor="#6666FF" style="border-left-style: solid; border-left-width: 1; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium">&nbsp;</td>
    </tr>
  </table>


    </center>
</div>


</body>
</html>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 15 13:01:28 2025 UTC