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>';
}



?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.