php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21916 fwrite writes sometimes strings twice in file
Submitted: 2003-01-28 03:06 UTC Modified: 2003-02-20 08:04 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: hematec at gmx dot de Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 4.3.0 OS: Win XP
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: hematec at gmx dot de
New email:
PHP Version: OS:

 

 [2003-01-28 03:06 UTC] hematec at gmx dot de
I had a 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=''+kriteri
um;
		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.artike
lnr.value;
		var kundennummer='';
		document.bestellen.kundennummer.value=top.oben.kundendaten.kundennumme
r.value;
		var session_nr='';
		document.bestellen.session_nr.value=top.oben.kundendaten.session_nr.va
lue;
		
		//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>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-28 03:21 UTC] magnus@php.net
Could you please provide a _SHORT_ script to reproduce it 
? 
 [2003-01-28 03:35 UTC] hematec at gmx dot de
$file_handler=fopen(test.txt,a);
fwrite($file_handler,'This is a test\n');
fclose($file_handler);

the funny thing is, that sometime this script produces only one entry and sometime it produces two entries in test.txt.

(i always delete the file before running the script.)

i'm using win xp pro
 [2003-02-09 10:52 UTC] moriyoshi@php.net
Similar to bug #20215
 [2003-02-20 08:04 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sat Oct 20 19:01:25 2018 UTC