Page 2 of 2

Posted: Tue Jul 27, 2004 10:10 pm
by feyd
I think it's more that the while loop is an infinite loop, always setting $dir to "Users", $warning isn't set anywhere in there, so it's blank when it hits the fopen call.

Posted: Wed Jul 28, 2004 2:39 am
by Simon Angell
$warning is set in the foreach() part?

so what do you suggest i do?
like i said, the fopen call works when i set $handle1 $handle2, $warning1, $warning2 etc etc...but to do it 50 times over seems a waste...

Posted: Wed Jul 28, 2004 8:35 pm
by Simon Angell
no clues?

Posted: Thu Jul 29, 2004 12:34 am
by Simon Angell
Ok... so i have the array/write setup like this

Code: Select all

<?php
$warnings = array($_POST[q],$_POST[q2],$_POST[q3],$_POST[q4],$_POST[q5]);
foreach ($warnings as $w){
$warning = $w;}

//then the file write code 

$rContents = "$filename";
$dir = "Users";
   if (!$handle = fopen("$dir/$warning", 'awb+')) { 
         echo "<br>Cannot open file ($warning)"; 
         exit; 
   } 

   // Write content to file. 
   if (fwrite($handle,"\r\n $rContents") === FALSE) { 
       echo "<br>Cannot write to file ($warning)"; 
       exit; 
   } 
    
   echo "<br>Success, wrote ($rContents) to file ($warning)"; 
    
   fclose($handle);


?>
ok, it will do what it is suppose to do (write file), only if the %_POST[q5] has been slectected on the HTML posting page, BUT will only write the one file, in this case...
<input name="q5" type="checkbox" value="Severe_Weather_Warning.txt"> Severe Weather Warning<br>

so $_POST[q5] = Severe_Weather_Warning.txt...
the result is (even with q4, q3, q2 selected...)
Success, wrote (AS_sss.txt) to file (Severe_Weather_Warning.txt)
(AS_sss.txt is $rContents/$filename ;))
IT should write the other files corrosponding with q2 q3 q4 etc etc but it doesn't..

WHEN q5 hasn't been selected on the html post page, the i get this error:
Warning: fopen(Users/): failed to open stream: Is a directory in /home/canberra/public_html/wwxs/adduser.php on line 48

Cannot open file ()


...

When i add in the while loop, and have q5 unslected, the same thing occurs, when i have q5 selected the while loop runs indefinatley, rewriting the same (q5) file over and over....

Strange but true...

Posted: Sun Aug 01, 2004 11:20 pm
by Simon Angell
any solutions to the above at all?

Posted: Sun Aug 15, 2004 1:29 am
by Simon Angell
just seeing if anyone can help me with the above at all?.....