Fwrite problem

Discussion in 'PHP' started by thesurface, Mar 24, 2010.

  1. #1
    this is my piece of my php code also do anyone know why its add $htaccess text for xample if i have folder admin it create file index.html with text from $htaccess = "example"; but if i have more that 1 folder the next index will include the text exampleexample and third index exampleexampleexample so its copiying example to every index and not replacing it :(

        $error_write = false;
        $error_create = false;
        $success = false;
        if(file_exists("index.html")){
            if(is_writable("index.html")){
                $fh = fopen("index.html", 'w') or $error_create = true;
                if($fh){
                    fwrite($fh, $htaccess);
                    fclose($fh);
                    $success = true;
                }
            }else{
                $error_write = true;
            }
        }else{
            $fh = fopen($file,"w+") or $error_create = true;
            if($fh){
                fwrite($fh, $htaccess);
                fclose($fh);
                $success = true;
            }
    PHP:
     
    thesurface, Mar 24, 2010 IP
  2. blacknet

    blacknet Active Member

    Messages:
    709
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    70
    #2
    you need to give more of the php script for context
     
    blacknet, Mar 24, 2010 IP
  3. Djhanzo

    Djhanzo Greenhorn

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    this is not the full script
     
    Djhanzo, Mar 24, 2010 IP