Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why is it doing this twice?

    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 Code:
    <?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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I took the script, dropped the variables and functions and it worked fine. Can I see the rest of the script?

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Which variables

    Which variables did you drop?

    I have attched all the files...
    Attached Files Attached Files

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    That is confusing

    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

  • #6
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all your help. I found out the problem...


    My web host is buggered and it runs everything twice!

    I put

    PHP Code:
    <?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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •