Web Analytics Made Easy -
StatCounter Help Please:Could someone tell me whats wrong with this script? - CodingForum

Announcement

Collapse
No announcement yet.

Help Please:Could someone tell me whats wrong with this script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help Please:Could someone tell me whats wrong with this script?

    <?
    $filename = 'test.txt';
    $name = $_REQUEST['sn'] ;
    $password = $_REQUEST['pass'] ;
    fopen($filename)
    fwrite($name, $password) ;
    fclose
    ?>

  • #2
    Parse error: parse error in c:\program files\easyphp1-8\www\handle.php on line 15
    ^thats the error message i get

    Comment


    • #3
      try this:

      <?
      $string = "Hello World!\n";
      $file = "test.txt";

      $fh = fopen($file, "w");
      fwrite($fh, $string);
      fclose($fh);

      echo ("Wrote \"$string\" to file $file");

      ?>

      Comment


      • #4
        thanks alot

        Comment


        • #5
          wait

          wait i used this and theres no errors but it still doesnt write to the file?


          <?
          $name = "sn";
          $password = "pass";
          $file = "test.php";
          $fh = fopen($file, "w");
          fwrite($fh, $name, $password);
          fclose($fh);
          ?>

          Comment


          • #6
            PHP Code:
            <?php
            $filename 
            './file.txt';
            $name 'sn';
            $password 'pass';


            $fh fopen($filename"w+b");
            if (
            fwrite($fh$name ':' $password) === FALSE)
            {
                 
            // This assumes you want a seperator of some sorts.  I used a colon :
                 
            die ('Cannot write to file ' $filename);
            }
            fclose($fh);
            Some things to consider. You may not have the permissions to write on the file. You can check this by using an is_writable function. If it returns false, you can attempt to chmod the file to 0700 or 0777.
            As with your previous code, you have stated the values of fwrite incorrectly. $password is not an integer value, so it will return as 0 in an attempt to write a length. As well, thought I'd mention that w+ will truncate and rewrite the file completely, not add to it, just in case your needing to append instead.
            PHP Code:
            header('HTTP/1.1 420 Enhance Your Calm'); 
            Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

            Comment

            Working...
            X