Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 567475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:05:12+00:00 2026-05-13T13:05:12+00:00

I am trying to write data from form inputs to a text file using

  • 0

I am trying to write data from form inputs to a text file using PHP. The file seems to load correctly, but does not write the data.

I have echoed the input values directly before trying to write to ensure they are not empty.

The text file is in the same directory as the php file.

I orginally got the error “Warning: fwrite(): supplied argument is not a valid stream resource” but corrected that by adjusting the permissions on the text file.

My current code

$fp = fopen('sidebar_subscribers.txt', 'a');
fwrite($fp, $name."\t".$email."\t".$leader."\t".$industry."\t".$country."\t".$zip."\r\n");
fclose($fp);

Why are the values not getting written to the text document?

Is there anything on the server that php needs to be set up for that I should check?

This is being used on a WordPress blog.

Thanks!

****** Issue is now resolved. The file was getting created and written in the wrong location. Thanks for all your help and suggestions. *******

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:05:13+00:00Added an answer on May 13, 2026 at 1:05 pm

    The code as written works for me; I’d suggest adding the following to determine where the error is happening:

    <?php    
      $fp = fopen('sidebar_subscribers.txt', 'a') or die('fopen failed');
    
      fwrite($fp, "$name\t$email\t$leader\t$industry\t$country\t$zip\r\n") or die('fwrite failed');
    ?>
    

    The original error about an invalid stream resource was a result of not checking your return values, which the “or die()” essentially does for you. fopen was failing, and returning false, and you were passing false as the first argument to fwrite.

    You can further check for errors by examining the return value of fwrite:

    <?php
    
    $ret = fwrite($fp, "$name\t$email\t$leader\t$industry\t$country\t$zip\r\n");
    
    if ($ret === false)
      die("Fwrite failed");
    echo ("fwrite wrote $ret bytes");
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some data from these vectors onto text files. When
I am trying to write my spatial data from a table to a file.
I am trying to write data stored in a binary file using turbo C++.
I want to write data into the file in binary form. I was trying
I'm trying to write a code to extract some form data from a HTML
I'm trying to write a javascript application that loads data from the openstreetmap API
I'm trying to read binary data from a specific offset. I write the data
I am trying to write our own RIA services provider to expose data from
I'm trying to write sql that produces the desired result from the data below.
I am trying write a function that generates simulated data but if the simulated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.