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

  • Home
  • SEARCH
  • 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 8813967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:59:30+00:00 2026-06-14T03:59:30+00:00

I have a script that is writing variables to a text file, I am

  • 0

I have a script that is writing variables to a text file, I am using fwrite(). here is the script:

<?php

error_reporting(E_ALL ^ E_NOTICE);

$filename = 'Report.txt';


$batch_id = $_GET['batch_id'];
$status = $_GET['status'];
$phone_number = $_GET['phone_number'];

//check to see if I could open the report.txt
    if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // I am trying to write each variables to the text file
    if (fwrite($handle, $phone_number) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

    echo "Success, wrote ($phone_number) to file ($filename)";

    fclose($handle);


?>

I have 2 problems here:

1.As I receive the report by Batch_ID I want to name each report text file with a prefix using the batch_ID for example :5626_Report.txt

2.I want to pass more than one variable to the function fwrite(), I want to write the $status next to each $phone_number.

  • 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-06-14T03:59:31+00:00Added an answer on June 14, 2026 at 3:59 am

    Try fprintf.

    It’s analogue to the regular printf of C, however you need to pass a handle to.
    As an example:

    fprintf($handle, "%s;%s;%s", $batch_id, $status, $phone_number);
    

    Alternatively, you can make use of PHPs inline stringing and use:

    fwrite($handle "$batch_id;$status;$phone_number");
    

    To get to your exact problem:

    $filename = $batch_id."_report.txt";
    $handle = fopen($filename, "a");
    fwrite($handle, "$phone_number $status");
    

    That should help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python script that is writing text to images using the PIL.
I'm writing a script that will ping my ip range. Here's what I have
I have a script that will write a given string to a text file...
I'm writing a bash script and I have errexit set, so that the script
I have script that reads remote file content and writes it to local server.
I have a script that resizes called resize Here is the script: <? echo
Im writing a php script that is used to update a database but it
C# : I have a string that comes from a webpage's sourcecode: <script type=text/javascript>
So I have been working on writing a script that takes in input from
I'm writing an application in PHP that uses a LOT of global variables that

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.