elite_prodigy Posted April 12, 2008 Share Posted April 12, 2008 I'm using the code below to open a CSS file and attempting to place it into a text box so the user can edit it. However, the texbox always comes up blank! What am I doing wrong? ??? <?php session_start(); if(isset($_SESSION[username]) || isset($_SESSION[id])){ $local = "overall.css"; $css_file = fopen($local, "w+"); $CSS = fread($css_file, 400000); fclose($css_file); } else{ header("location: login.php"); } ?> <html> <head> <title></title> <style> @import URL("overall.css"); </style> </head> <body> <br /> <br /> <br /> <br /> <br /> <br /> <table class="body"> <tr> <td class="top_left">.</td> <td class="top_center"><script type="text/javascript" src="http://x10hosting.com/adserve.js?corporate"></script></td> <td class="top_right">.</td> </tr> <tr> <td class="center_left"></td> <td class="middle"> <form method="post" action="edit_style.php"> <textarea name="css" rows="35" cols="75" wrap="virtual"><?php echo $CSS; ?></textarea> </form> </td> <td class="center_right"></td> </tr> <tr> <td class="bottom_left">.</td> <td class="bottom_center"><center>Copyright © 2008 Expose Your School</center></td> <td class="bottom_right">.</td> </tr> </table> <br /> <br /> <br /> <br /> <br /> <br /> </body> </html> Link to comment https://forums.phpfreaks.com/topic/100819-blank-file-with-fread/ Share on other sites More sharing options...
elite_prodigy Posted April 12, 2008 Author Share Posted April 12, 2008 *bump* Does anyone know what I did wrong? Link to comment https://forums.phpfreaks.com/topic/100819-blank-file-with-fread/#findComment-515592 Share on other sites More sharing options...
PFMaBiSmAd Posted April 12, 2008 Share Posted April 12, 2008 You might want to read what the w+ mode means - Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. Link to comment https://forums.phpfreaks.com/topic/100819-blank-file-with-fread/#findComment-515645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.