fopen error

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

PHP Code: [ Select ]
<?php
 
     
 
$filename ="filename and dir here";    
 
               
 
 
 
$myFile= fopen($filename,'a+');    
 
if(! $myFile){                      
 
 
 
echo '<div align="center">
 
       <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
 
         <tr>
 
           <td><b>test</b></font></td>
 
           <td align="center" width="40%"><font color="#cc0000"><strong>Failed!</strong></font></td>
 
         </tr>
 
       </table></div><br>';
 
         
 
}
 
 
 
$string = "blah blah blah, blah blah blah";    
 
     
 
fputs($myFile, $string);    
 
 
 
fclose($myFile);        
 
 
 
echo '<div align="center">
 
       <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
 
         <tr>
 
           <td><b>test</b></td>
 
           <td align="center" width="40%"><font color="#003399"><strong>Successful!</strong></font></td>
 
         </tr>
 
       </table></div><br>';
 
?>
 
 
  1. <?php
  2.  
  3.      
  4.  
  5. $filename ="filename and dir here";    
  6.  
  7.                
  8.  
  9.  
  10.  
  11. $myFile= fopen($filename,'a+');    
  12.  
  13. if(! $myFile){                      
  14.  
  15.  
  16.  
  17. echo '<div align="center">
  18.  
  19.        <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
  20.  
  21.          <tr>
  22.  
  23.            <td><b>test</b></font></td>
  24.  
  25.            <td align="center" width="40%"><font color="#cc0000"><strong>Failed!</strong></font></td>
  26.  
  27.          </tr>
  28.  
  29.        </table></div><br>';
  30.  
  31.          
  32.  
  33. }
  34.  
  35.  
  36.  
  37. $string = "blah blah blah, blah blah blah";    
  38.  
  39.      
  40.  
  41. fputs($myFile, $string);    
  42.  
  43.  
  44.  
  45. fclose($myFile);        
  46.  
  47.  
  48.  
  49. echo '<div align="center">
  50.  
  51.        <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
  52.  
  53.          <tr>
  54.  
  55.            <td><b>test</b></td>
  56.  
  57.            <td align="center" width="40%"><font color="#003399"><strong>Successful!</strong></font></td>
  58.  
  59.          </tr>
  60.  
  61.        </table></div><br>';
  62.  
  63. ?>
  64.  
  65.  


ok theres my code above....

what i want
Ok, Where it says
PHP Code: [ Select ]
if(! $myFile){  
i want the error message below it to show if it could not get the file. If it does, then i dont want it to show that message at all afterwards. Instead go down the code and show the last message.

Even though it dont work the last message still shows up.... i tried....


PHP Code: [ Select ]
<?php
 
     
 
$filename ="filename and dir here";    
 
               
 
 
 
$myFile= fopen($filename,'a+');    
 
if(! $myFile){                      
 
 
 
echo '<div align="center">
 
       <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
 
         <tr>
 
           <td><b>test</b></font></td>
 
           <td align="center" width="40%"><font color="#cc0000"><strong>Failed!</strong></font></td>
 
         </tr>
 
       </table></div><br>';
 
         
 
} else {
 
echo '<div align="center">
 
       <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
 
         <tr>
 
           <td><b>test</b></td>
 
           <td align="center" width="40%"><font color="#003399"><strong>Successful!</strong></font></td>
 
         </tr>
 
       </table></div><br>';  }
 
 
 
$string = "blah blah blah, blah blah blah";    
 
     
 
fputs($myFile, $string);    
 
 
 
fclose($myFile);        
 
 
 
 
 
?>
 
 
 
 
 
 
 
 
  1. <?php
  2.  
  3.      
  4.  
  5. $filename ="filename and dir here";    
  6.  
  7.                
  8.  
  9.  
  10.  
  11. $myFile= fopen($filename,'a+');    
  12.  
  13. if(! $myFile){                      
  14.  
  15.  
  16.  
  17. echo '<div align="center">
  18.  
  19.        <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
  20.  
  21.          <tr>
  22.  
  23.            <td><b>test</b></font></td>
  24.  
  25.            <td align="center" width="40%"><font color="#cc0000"><strong>Failed!</strong></font></td>
  26.  
  27.          </tr>
  28.  
  29.        </table></div><br>';
  30.  
  31.          
  32.  
  33. } else {
  34.  
  35. echo '<div align="center">
  36.  
  37.        <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
  38.  
  39.          <tr>
  40.  
  41.            <td><b>test</b></td>
  42.  
  43.            <td align="center" width="40%"><font color="#003399"><strong>Successful!</strong></font></td>
  44.  
  45.          </tr>
  46.  
  47.        </table></div><br>';  }
  48.  
  49.  
  50.  
  51. $string = "blah blah blah, blah blah blah";    
  52.  
  53.      
  54.  
  55. fputs($myFile, $string);    
  56.  
  57.  
  58.  
  59. fclose($myFile);        
  60.  
  61.  
  62.  
  63.  
  64.  
  65. ?>
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
but then it wont work at all, because its just doing if statements and there is also an else which stops it from going anywhere else below it. In my opinion im getting a feeling that the else statement is where the script is stopping at. It thinks its the end of the code.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

i have now just tried

PHP Code: [ Select ]
 
<?php
 
     
 
$filename ="filename and directory";  
 
               
 
 
 
$myFile= fopen($filename,'a+');    
 
if(! $myFile){                  
 
 
 
echo '<div align="center">
 
       <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
 
         <tr>
 
           <td><b>test</b><br><font size="2"><i>Please make sure you have chmodd the req folder to 777</i></font></td>
 
           <td align="center" width="40%"><font color="#cc0000"><strong>Failed!</strong></font></td>
 
         </tr>
 
        </table></div><br>';     
 
}
 
 
 
$string = "dsadsadsadsadsadsadsadsadsa";  
 
     
 
 
 
$putfile = fputs($myFile, $string);  
 
 
 
if( $putfile){
 
 
 
echo='<div align="center">
 
       <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
 
         <tr>
 
           <td><b>test</b></td>
 
           <td align="center" width="40%"><font color="#003399"><strong>Successful!</strong></font></td>
 
         </tr>
 
       </table></div><br><br>'; }
 
     
 
fclose($myFile);      
 
 
 
}
 
     
 
 
 
?>
 
 
  1.  
  2. <?php
  3.  
  4.      
  5.  
  6. $filename ="filename and directory";  
  7.  
  8.                
  9.  
  10.  
  11.  
  12. $myFile= fopen($filename,'a+');    
  13.  
  14. if(! $myFile){                  
  15.  
  16.  
  17.  
  18. echo '<div align="center">
  19.  
  20.        <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
  21.  
  22.          <tr>
  23.  
  24.            <td><b>test</b><br><font size="2"><i>Please make sure you have chmodd the req folder to 777</i></font></td>
  25.  
  26.            <td align="center" width="40%"><font color="#cc0000"><strong>Failed!</strong></font></td>
  27.  
  28.          </tr>
  29.  
  30.         </table></div><br>';     
  31.  
  32. }
  33.  
  34.  
  35.  
  36. $string = "dsadsadsadsadsadsadsadsadsa";  
  37.  
  38.      
  39.  
  40.  
  41.  
  42. $putfile = fputs($myFile, $string);  
  43.  
  44.  
  45.  
  46. if( $putfile){
  47.  
  48.  
  49.  
  50. echo='<div align="center">
  51.  
  52.        <table width="60%" border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 dashed;">
  53.  
  54.          <tr>
  55.  
  56.            <td><b>test</b></td>
  57.  
  58.            <td align="center" width="40%"><font color="#003399"><strong>Successful!</strong></font></td>
  59.  
  60.          </tr>
  61.  
  62.        </table></div><br><br>'; }
  63.  
  64.      
  65.  
  66. fclose($myFile);      
  67.  
  68.  
  69.  
  70. }
  71.  
  72.      
  73.  
  74.  
  75.  
  76. ?>
  77.  
  78.  


and this dont work at all

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 38 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.