...

View Full Version : Why is it doing this twice?



missing-score
03-02-2003, 11:53 AM
I am making a system for the main page of my site, where admins can add a news item to the page using PHP ( like a message board. )

I have used a simple code for adding links to the page ect ( like the one on here, but when I try and post the message, it posts 2 of them, 2 of the same message.

I have checked about everything I can think of, and It doesn't seem to help. Down to this basic code below, it still posts 2 messages.

Can anyone help and tell my WHY?


<?php
$subj = rmvHTML($subject);
$pmsg = rmvHTML($message); // rmvHTML replaces < and > with &lt; and &gt;
$pmsg = toCode($message); // toCode replaces stuff like [BOLD] with <strong>

$amFile = fopen('newslog.dat','a');
flock($amFile,2);

fwrite($amFile,"\n\n<!-- START NEW POST -->\n<center>
<table width=\"590\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"300\" colspan=\"300\" style=\"border:1px solid #999999; border-right:0px; padding-left:8px\" bgcolor=\"#EEEEEE\"><p id=\"form\"><img src=\"itkb/bullet1.gif\" />$subj</p></td>
<td width=\"290\" colspan=\"290\" style=\"border:1px solid #999999; border-left:0px; padding-left:8px\" bgcolor=\"#EEEEEE\" align=\"right\"><p id=\"small\">Posted By: $user<img src=\"pixel.gif\" width=\"5\" height=\"1\" /></td>
</tr>
<tr>
<td width=\"590\" colspan=\"590\" style=\"border:1px solid #999999; border-top:0px; padding-left:21px; padding-top:4px; padding-bottom:0px; padding-right:4px\" bgcolor=\"#FFFFFF\"><p id=\"small\">$pmsg</p>
<p id=\"small\" align=\"right\"><a class=\"nvs2\" href=\"mailto:$mail\">e-mail this person</a> | <a class=\"nvs2\" href=\"$site\">visit site</a> | <a class=\"nvs2\" href=\"$rel\">similar topics</a>
</td>
</tr>
</table>
</center>
<br /><br />\n\n<!-- END POST -->");

flock($amFile,3);
fclose($amFile);
?>


Thanks!
( If you need to have a look at the layout ( i dont think that would be a problem ) then go to http://www.itoolkit.net/itk

x_goose_x
03-02-2003, 05:45 PM
I took the script, dropped the variables and functions and it worked fine. Can I see the rest of the script?

missing-score
03-02-2003, 06:17 PM
Which variables did you drop?

I have attched all the files...

x_goose_x
03-02-2003, 11:40 PM
After looking at your script it looks like it should work as is. Dunno? I did play around a bit and switched from append to write on the line (additem.php):

$amFile = fopen('newslog.dat','w');

and it works. Don't know why, but it does.

missing-score
03-03-2003, 08:03 AM
I really cant understand that!!! It works. The trouble is it destroys all the old information.

I thought I had picked this up pretty well, but now I'm really confused, like the time I forgot my name ( JUST KIDDING!!! )

Thanks anyway. If anyone else can help, plz do...

Matt

missing-score
03-03-2003, 09:20 PM
Thanks for all your help. I found out the problem...


My web host is buggered and it runs everything twice!

I put



<?php

$fp = fopen('newslog.dat','a');

fwrite($fp,'Hello<br />');

fclose($fp);

?>


and it still wrote it in twice. It also sent mail twice aswell! my friends got annoyed lol.

I am still under the refund and It also doesnt have the power I need to run my site anyway ( I need MySQL for the forum I am making ) and I found this site ( http://www.icdsoft.com ) which is REALLY deacent.

Cheers!
Matt



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum