Results 1 to 3 of 3

Thread: whats wrong with this?

  1. #1
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default whats wrong with this?

    i want to delete everything in the file so to make it easy for myself, i made it delete the file, then rewrite it... so why wont it work?

    PHP Code:
    <?php include('mysql.php'); ?>
    <?
    $username 
    $_COOKIE['ID_my_site']; 
    $wordfile "chatbox.txt"
    $word $_POST['word']; 
      
    $contentword file_get_contents($ipfile); 
    $cword explode("\r\n",$contentword); 
    if(!
    $wordfile) {die("No such file. Go <a href=\"chat.php\">back</a>.");}; 
    $in array_search($username$cword);
    $pass $_COOKIE['Key_my_site'];
    $check mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    while(
    $info mysql_fetch_array$check )) {

    if(isset(
    $word)) {
    if(
    $username != "Demonicman"){
    die(
    'You are not an admin!');
    };  
    /* Delete File */ 
    unlink($wordfile);

    /* Rewrite File */
    $FileHandle fopen($wordfile'w') or die("can't create file");
    fclose($FileHandle);


    /* Echo Out continue */ 
        
    echo '<a href="chat.php">Continue</a>';
      }; 
    }
    ?>
    http://www.insanecombat.com << bored? check out ma game

  2. #2
    Join Date
    Mar 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    try this:

    (it may be unsetting the var)

    /* Delete File */
    $newFile = $wordfile;
    unlink($wordfile);

    /* Rewrite File */
    $FileHandle = fopen($newFile, 'w') or die("can't create file");
    fclose($FileHandle);

    If that doesn't work I'd be glad to take a closer look at it, just don't have time right now

  3. #3
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    nope didnt work... im also having trouble with the actual chat...

    PHP Code:
    <?php include('mysql.php'); ?>
    <?
    $username 
    $_COOKIE['ID_my_site'];
    $pass $_COOKIE['Key_my_site']; 
    $wordfile "chatbox.txt"
    $word htmlentities($_POST['word']); 
       
    if(!
    $wordfile) {
    die(
    "No such file. Go <a href=\"chat.php\">back</a>.");
    };

    $check mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    while(
    $info mysql_fetch_array$check )) {

    if(isset(
    $word)) {  
    /* Write message */ 
        
    $handip fopen($wordfile,"r+");
        
    fseek($handip0);
        
    fwrite($handip,"\r\n" $username " - " $word ."\r\n"); 
        
    fclose($handip); 
    /* Relocate */
    header("Location: chat.php");
      }; 
    }
    ?>
    its just overwriting what i already chatted
    Last edited by Demonicman; 03-07-2007 at 11:25 PM.
    http://www.insanecombat.com << bored? check out ma game

Bookmarks

Posting Permissions

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