Jump to content

(FWRITE) I messed this up and can't figure out what I did


JREAM

Recommended Posts

If anyone is able to help please do! I had it working but I was trying to change some things and it went bad, no E_ALL errors but it won't write:

 

<?php

$dir = "data/blocks/";

    
function showblocks() {

    global $dir;

    print '<div class="tabber">';

    foreach (glob ("$dir{*.php}", GLOB_BRACE) as $blocks) {
        $frmt = str_replace('.php', '', basename($blocks));
        
        block($frmt, $frmt);

        }
    
echo '</div>';

}



function block($name, $title){

    global $dir;

    if (isset($_POST['$name'])) {

        $dir = "data/blocks/" . $name;
        $fp = fopen ($filename, "w");

        if ($fp) {
            fwrite ($fp, $text);
            fclose ($fp);
            }
        }

        print '
        <div class="tabbertab">
        <h2>' . $title . '</h2>' . $name . '<br />
        <form name="' . $name . '" method="post" action="?action=showblocks">
        <textarea name="' . $name . '" cols="90" rows="10">
        ';

        include($dir . $name . '.php');

        print '</textarea>
        <br />
        <input class="b" type="submit" name="sub" value="Save Changes" />
        </form>
        </div>';
}



?>

Well, you're writing with this line:

 

fwrite ($fp, $text);

 

However, $text is undefined. Therefore, nothing is getting written to the file. I can't help you further without seeing more of your code. I suspect that either you need to pass $text to the function or that $text is supposed to be $name or $title.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.