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 8979031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:45:04+00:00 2026-06-15T19:45:04+00:00

Suppose that I have the PHP function as below: function.php <?php function getDataInFile($PMTA_FILE){ $PMTA_DATE

  • 0

Suppose that I have the PHP function as below:

function.php

<?php
function getDataInFile($PMTA_FILE){
    $PMTA_DATE = date("Y-m-d");
    $lineFromText = explode("\n", $PMTA_FILE);
    $number_bar_charts = 13;
    $row = 0;
    $cate = "";
    $total ="";
    $fail = "";
    $mailSuc = "";
    $title = "";
       foreach($lineFromText as $line){
            if($row < $number_bar_charts){
              $words = explode(";",$line);
              $dateTime .= ','.$words[0];
                if($title == ""){
                   $title = $words[0];
                }
                $cate .= ','."'$words[5]'";
                $total .= ','.$words[6];
                $fail .= ','.$words[7];
                $mailSuc .= ','.((int)$words[6] - (int)$words[7]);                          
            $row++;
      }   
     }

}


?>

This is code below that I call the function to use in getFile.php.

<?php 
include("include/function.php");
$PMTA_DATE = date("Y-m-d");
getDataInFile("../stats_domain_recepteur.affinitead.net.".$PMTA_DATE.".txt");

?>

In fact, it can not read data from the file, I got the error messages Undefined variable: dateTime in C:\wamp\www\chat\include\function.php on line 15,Notice: Undefined offset: 5 in C:\wamp\www\chat\include\function.php on line 19….

I do not know how to fix this, Anyone help me please, Thanks.

  • 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-15T19:45:05+00:00Added an answer on June 15, 2026 at 7:45 pm

    These are Notices only. They are not terrible errors that will blow up your code, but some code reviewers would make you fix them. PHP is just giving you a polite nudge, but will work anyhow. Fatal errors are the big, bad problems that will stop PHP in its tracks.

    Here are the problems PHP found…

    1. You’re appending data to the string $dateTime on each iteration. On the first pass through the variable doesn’t yet exist. PHP doesn’t really care, but will issue a warning. To get rid of that problem, define $dateTime before you use it.

      $dateTime = null;

    2. The second problem is an array out of bounds exception. You are trying to do something with $words[5] when that array index doesn’t exist. In general, you should check that array indexes, variables and other fun stuff actually exist before you try to use them.

      $cate .= sprintf(",'%s'", isset($word[5]) ? $word[5] : '');

    If you don’t want to see Notices and Warnings reported in the error log, see PHP Error Handling to learn how to set which error levels you want to see in your log.

    You should also read all about the file_get_contents function to actually get the file in the first place!

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

Sidebar

Related Questions

Suppose that I have below code: <?php $html = ' <form id=formA> <!-- Form
Suppose that I have the PHP code as below: class modual { public $glo;
Suppose I have a example.php file like that: <p> <?php echo _('Hello world') ?>
Suppose that you have a function f: List a -> a such that f
Suppose that I have a database query which looks like below - select name,
Suppose I have a PHP script that returns a json response. It looks something
I have the php webservice code below, what I am suppose to do, so
Suppose that I have a date Jan 31 2011 and I want to add
This is a general question. Using an example below, suppose that I have a
I have a PHP script that's supposed to take in a URL and search

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.