ID:               21916
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         Filesystem function related
 Operating System: Win XP
 PHP Version:      4.3.0
 New Comment:

Similar to bug #20215


Previous Comments:
------------------------------------------------------------------------

[2003-01-28 03:35:07] [EMAIL PROTECTED]

$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-01-28 03:21:08] [EMAIL PROTECTED]

Could you please provide a _SHORT_ script to reproduce it 
? 

------------------------------------------------------------------------

[2003-01-28 03:06:19] [EMAIL PROTECTED]

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>


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21916&edit=1

Reply via email to