By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

function createNewFile() (user defined) isnt creating a new file...

eragon
100+
P: 431
I wrote this function to create a new file when the user posts in my forums, and its not creating a new file, can you help me? this script is not copyrighted as the last one.

Expand|Select|Wrap|Line Numbers
  1. function createNewFile($name,$mail,$subject,$comments,$count,$date,$other="",$up="0") {
  2. global $settings;
  3. $header=implode('',file('header.txt'));
  4. $footer=implode('',file('footer.txt'));
  5. $content='
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  7. <html>
  8. <head>
  9. <title>PKC - Forums - '.$subject.'</title>
  10. <meta content="text/html; charset=windows-1250">
  11. <link href="'.$settings['mboard_url'].'/../basic-1.css" type="text/css" rel="stylesheet">
  12. <META HTTP-EQUIV="Expires" CONTENT="-1">
  13. <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  14. <script language="Javascript" src="'.$settings['mboard_url'].'/javascript.js"><!--
  15. //-->
  16. </script>
  17. </head>
  18. <body>
  19. <div id="body">';
  20. $content.=$header;
  21.  
  22. $content.='<div class="title frame e">
  23. '.$settings['mboard_title'].'<br><a href="../index.php">Main Menu |
  24. <a href="'.$settings['mboard_url'].'/mboard.php">'.$settings['mboard_title'].'</a></a></div>
  25.  
  26. <div align="center"><center>
  27. <table border="0" width="95%"><tr>
  28. <td>
  29.  
  30. <p align="center"><a href="?new">Post a reply</a></p>
  31. <hr>
  32. <p><div class="e"><?php
  33. if ($_SESSION[\'status\'] == \'admin\') {echo(\'<p><a href=\"'.$settings['mboard_url'].'/mboard.php?a=delete&num='.$count.'&up='.$up.'\"><img
  34. src='.$settings['mboard_url'].'/images/delete.gif" width="16" height="14" border="0" alt="Delete this post"></a><hr>\'); \?>
  35. <p><b>'.$subject.'</b><span style="float:right;">Submitted by <span class="'.$_SESSION['status'].'">'.$name.'</span> on '.$date.'</span><hr>';
  36. $content .= '</p>
  37.  
  38. <p><b>Message</b>:</p>
  39.  
  40. <p>'.$comments.'</p>';
  41.  
  42. if ($settings['display_IP']==1) {$content .= '<hr><font class="ip">User\'s IP: '.$_SERVER['REMOTE_ADDR'].'</font>';}
  43.  
  44. $content .= '</div>
  45.  
  46. <p align="center" class="e"><b>Replies to this post</b></p>
  47. <ul>
  48. <!-- zacni --><p class="e">No replies yet</p>
  49. </ul>
  50. <hr></td>
  51. </tr></table>
  52. </center></div><?php
  53.  
  54. if ($_GET[\'new\']) {
  55.     echo(\'
  56.  
  57. <div class="e"><p align="center"><a name="new"></a><b>Reply to this post</b></p>
  58. <div align="center"><center>
  59. <table border="0"><tr>
  60. <td>
  61. <form method=post action="'.$settings['mboard_url'].'/mboard.php" name="form" onSubmit="return mboard_checkFields();">
  62. <p><input type="hidden" name="a" value="reply"><b>Name:</b><br><input type=text name="name" size=30 maxlength=30><br>
  63. E-mail (optional):<br><input type=text name="email" size=30 maxlength=50><br>
  64. <b>Subject:</b><br><input type=text name="subject" value="Re: '.$subject.'" size=30 maxlength=100><br><br>
  65. <b>Message:</b><br><textarea cols=50 rows=9 name="message"></textarea>
  66. <input type="hidden" name="orig_id" value="'.$count.'">
  67. <input type="hidden" name="orig_name" value="'.$name.'">
  68. <input type="hidden" name="orig_subject" value="'.$subject.'">
  69. <input type="hidden" name="orig_date" value="'.$date.'"><br>
  70. Insert styled text: <a href="javascript:insertspecial(\'B\')"><b>Bold</b></a> |
  71. <a href="javascript:insertspecial(\'I\')"><i>Italic</i></a> |
  72. <a href="javascript:insertspecial(\'U\')"><u>Underlined</u></a><br>
  73. <input type="checkbox" name="nostyled" value="Y"> Disable styled text</p>
  74. \');} else{} ?>';
  75.  
  76. if ($settings['smileys']) {
  77.     $content.='
  78.     <p><a href="javascript:openSmiley(\''.$settings['mboard_url'].'/smileys.htm\')">Insert smileys</a>
  79.     (Opens a new window)<br><input type="checkbox" name="nosmileys" value="Y"> Disable smileys</p>
  80.     ';
  81. }
  82.  
  83. $content.='
  84. <p><input type=submit value="Submit reply">
  85. </form>
  86. </td>
  87. </tr></table>
  88. </center></div>
  89. </div>';}
  90.  
  91. $content.=$footer;
  92. $content.='</div>
  93. </body>
  94. </html>';
  95.  
  96. $newfile="msg/".$count.".".$settings['extension'];
  97. $fp = fopen($newfile,"wb") or problem("Couldn't create file &quot;$newfile&quot;! Please CHMOD the &quot;msg&quot; folder to 666 (rw-rw-rw)!");
  98. if (flock($fp, LOCK_EX)) {
  99.     fputs($fp,$content);
  100.     flock($fp, LOCK_UN);
  101. } else {
  102.     echo "Error locking a file, please try again later!";
  103. }
  104. //end new file 
  105. fclose($fp);
  106.  
  107. unset($content);
  108. unset($header);
  109. unset($footer);
  110.  
as i said, its not creating the new file, and i chmodded the folder its supposed to write to 777. any ideas?
Jul 8 '07 #1
Share this Question
Share on Google+
5 Replies


mwasif
Expert 100+
P: 801
Change line 97 code to

[PHP]$fp = fopen($newfile,"wb") or problem("Couldn't create file \"$newfile\"! Please CHMOD the \"msg\" folder to 666 (rw-rw-rw)!");[/PHP]
Jul 8 '07 #2

mwasif
Expert 100+
P: 801
I think you disabled error_reporting.
Jul 8 '07 #3

eragon
100+
P: 431
i had the "s written as &quot; but the TSDN forums see that and change iit to ", so, that fix might not work.
Jul 8 '07 #4

eragon
100+
P: 431
@%#&! it still dosnt wite the file. the whole purpose is to wirte the files with the names in increasing order, as based on the counter file count.txt. so, it will make 1.php 2.php and so on. and those are the ids for the threads. i cant find the error! ill check the script that calls the function again... check for case sensitive matching. Maybe i just need to restore the whole section to the origional version and start ALL over... i hope not.
Jul 8 '07 #5

eragon
100+
P: 431
problem still stands, can you help me with it?
Jul 9 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.