retrieve variables in a txt of multiple values in php











up vote
0
down vote

favorite












content in txt file:



<test@test.com>: connect to test.com[00.00.00.0]:0: Connection timed out
recipient=test@test.com
offset=00000
status=0.0.0
action=delayed
reason=connect to test.com[00.00.00.0]:0: Connection timed out


<test234@test234.com>: connect to e-mail.com[00.00.00.0]:0: Connection timed out
recipient=test234@test234.com
offset=00000
status=0.0.0
action=delayed
reason=connect to test234.com[00.00.00.0]:0: Connection timed out


I need to get in variables in the txt file:
for example:



$email =    test234@test234.com
$content = : connect to e-mail.com[00.00.00.0]:0: Connection timed out
recipient=test234@test234.com
offset=00000
status=0.0.0
action=delayed
reason=connect to test234.com[00.00.00.0]:0: Connection timed out


I try but not working



<?php 
$connect = mysql_connect('localhost','root','');
if(!$connect)
{
die('Could not connect:' . mysql_error());
}
mysql_select_db('test',$connect);


// txt file

$file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

while ( ($line = fgets($file)) !== false) {

// get the email <email@email.com>
preg_match_all('/<(.+)>/', $line, $coincidencias);

foreach ($coincidencias[1] AS $email)
{
// create a query and insert into database
$sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."',' $description (the description)',now());";

echo '<pre>'.$sql. '</pre>';
mysql_query($sql);
}
}


I can not find the right way how to do it
I need to get them in variables for storage in databases.










share|improve this question




























    up vote
    0
    down vote

    favorite












    content in txt file:



    <test@test.com>: connect to test.com[00.00.00.0]:0: Connection timed out
    recipient=test@test.com
    offset=00000
    status=0.0.0
    action=delayed
    reason=connect to test.com[00.00.00.0]:0: Connection timed out


    <test234@test234.com>: connect to e-mail.com[00.00.00.0]:0: Connection timed out
    recipient=test234@test234.com
    offset=00000
    status=0.0.0
    action=delayed
    reason=connect to test234.com[00.00.00.0]:0: Connection timed out


    I need to get in variables in the txt file:
    for example:



    $email =    test234@test234.com
    $content = : connect to e-mail.com[00.00.00.0]:0: Connection timed out
    recipient=test234@test234.com
    offset=00000
    status=0.0.0
    action=delayed
    reason=connect to test234.com[00.00.00.0]:0: Connection timed out


    I try but not working



    <?php 
    $connect = mysql_connect('localhost','root','');
    if(!$connect)
    {
    die('Could not connect:' . mysql_error());
    }
    mysql_select_db('test',$connect);


    // txt file

    $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

    while ( ($line = fgets($file)) !== false) {

    // get the email <email@email.com>
    preg_match_all('/<(.+)>/', $line, $coincidencias);

    foreach ($coincidencias[1] AS $email)
    {
    // create a query and insert into database
    $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."',' $description (the description)',now());";

    echo '<pre>'.$sql. '</pre>';
    mysql_query($sql);
    }
    }


    I can not find the right way how to do it
    I need to get them in variables for storage in databases.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      content in txt file:



      <test@test.com>: connect to test.com[00.00.00.0]:0: Connection timed out
      recipient=test@test.com
      offset=00000
      status=0.0.0
      action=delayed
      reason=connect to test.com[00.00.00.0]:0: Connection timed out


      <test234@test234.com>: connect to e-mail.com[00.00.00.0]:0: Connection timed out
      recipient=test234@test234.com
      offset=00000
      status=0.0.0
      action=delayed
      reason=connect to test234.com[00.00.00.0]:0: Connection timed out


      I need to get in variables in the txt file:
      for example:



      $email =    test234@test234.com
      $content = : connect to e-mail.com[00.00.00.0]:0: Connection timed out
      recipient=test234@test234.com
      offset=00000
      status=0.0.0
      action=delayed
      reason=connect to test234.com[00.00.00.0]:0: Connection timed out


      I try but not working



      <?php 
      $connect = mysql_connect('localhost','root','');
      if(!$connect)
      {
      die('Could not connect:' . mysql_error());
      }
      mysql_select_db('test',$connect);


      // txt file

      $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

      while ( ($line = fgets($file)) !== false) {

      // get the email <email@email.com>
      preg_match_all('/<(.+)>/', $line, $coincidencias);

      foreach ($coincidencias[1] AS $email)
      {
      // create a query and insert into database
      $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."',' $description (the description)',now());";

      echo '<pre>'.$sql. '</pre>';
      mysql_query($sql);
      }
      }


      I can not find the right way how to do it
      I need to get them in variables for storage in databases.










      share|improve this question















      content in txt file:



      <test@test.com>: connect to test.com[00.00.00.0]:0: Connection timed out
      recipient=test@test.com
      offset=00000
      status=0.0.0
      action=delayed
      reason=connect to test.com[00.00.00.0]:0: Connection timed out


      <test234@test234.com>: connect to e-mail.com[00.00.00.0]:0: Connection timed out
      recipient=test234@test234.com
      offset=00000
      status=0.0.0
      action=delayed
      reason=connect to test234.com[00.00.00.0]:0: Connection timed out


      I need to get in variables in the txt file:
      for example:



      $email =    test234@test234.com
      $content = : connect to e-mail.com[00.00.00.0]:0: Connection timed out
      recipient=test234@test234.com
      offset=00000
      status=0.0.0
      action=delayed
      reason=connect to test234.com[00.00.00.0]:0: Connection timed out


      I try but not working



      <?php 
      $connect = mysql_connect('localhost','root','');
      if(!$connect)
      {
      die('Could not connect:' . mysql_error());
      }
      mysql_select_db('test',$connect);


      // txt file

      $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

      while ( ($line = fgets($file)) !== false) {

      // get the email <email@email.com>
      preg_match_all('/<(.+)>/', $line, $coincidencias);

      foreach ($coincidencias[1] AS $email)
      {
      // create a query and insert into database
      $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."',' $description (the description)',now());";

      echo '<pre>'.$sql. '</pre>';
      mysql_query($sql);
      }
      }


      I can not find the right way how to do it
      I need to get them in variables for storage in databases.







      php text text-files






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 6:38









      Cœur

      17k9102140




      17k9102140










      asked Jan 29 '13 at 14:36









      Eduardo

      1




      1
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          $connect = mysql_connect('localhost','root','');
          if(!$connect)
          {
          die('Could not connect:' . mysql_error());
          }
          mysql_select_db('test',$connect);


          // txt file

          $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

          $i = 0;

          while ( ($line = fgets($file)) !== false) {

          // get the email <email@email.com>
          if (preg_match('/<(.+)>/', $line, $email)) {
          $coincidencias = $email[1];
          }
          if (strlen(trim($line)) > 0) {
          $still_empty = false;
          $content[$i] .= preg_replace('/<.+>: /', '', $line);
          } else {
          if (!$still_empty) {
          $i++;
          }
          $still_empty = true;
          }
          }

          $i = 0;
          foreach ($coincidencias as $email)
          {
          // create a query and insert into database
          $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."','".$content[$i]."',now());";
          echo '<pre>'.$sql.'</pre>';
          $i++;
          mysql_query($sql);
          }





          share|improve this answer























          • Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
            – Eduardo
            Jan 29 '13 at 16:31












          • @Eduardo What do you mean by do not know what to do? What kind of help do you need?
            – Antony
            Jan 29 '13 at 16:32











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14585379%2fretrieve-variables-in-a-txt-of-multiple-values-in-php%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          $connect = mysql_connect('localhost','root','');
          if(!$connect)
          {
          die('Could not connect:' . mysql_error());
          }
          mysql_select_db('test',$connect);


          // txt file

          $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

          $i = 0;

          while ( ($line = fgets($file)) !== false) {

          // get the email <email@email.com>
          if (preg_match('/<(.+)>/', $line, $email)) {
          $coincidencias = $email[1];
          }
          if (strlen(trim($line)) > 0) {
          $still_empty = false;
          $content[$i] .= preg_replace('/<.+>: /', '', $line);
          } else {
          if (!$still_empty) {
          $i++;
          }
          $still_empty = true;
          }
          }

          $i = 0;
          foreach ($coincidencias as $email)
          {
          // create a query and insert into database
          $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."','".$content[$i]."',now());";
          echo '<pre>'.$sql.'</pre>';
          $i++;
          mysql_query($sql);
          }





          share|improve this answer























          • Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
            – Eduardo
            Jan 29 '13 at 16:31












          • @Eduardo What do you mean by do not know what to do? What kind of help do you need?
            – Antony
            Jan 29 '13 at 16:32















          up vote
          0
          down vote













          $connect = mysql_connect('localhost','root','');
          if(!$connect)
          {
          die('Could not connect:' . mysql_error());
          }
          mysql_select_db('test',$connect);


          // txt file

          $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

          $i = 0;

          while ( ($line = fgets($file)) !== false) {

          // get the email <email@email.com>
          if (preg_match('/<(.+)>/', $line, $email)) {
          $coincidencias = $email[1];
          }
          if (strlen(trim($line)) > 0) {
          $still_empty = false;
          $content[$i] .= preg_replace('/<.+>: /', '', $line);
          } else {
          if (!$still_empty) {
          $i++;
          }
          $still_empty = true;
          }
          }

          $i = 0;
          foreach ($coincidencias as $email)
          {
          // create a query and insert into database
          $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."','".$content[$i]."',now());";
          echo '<pre>'.$sql.'</pre>';
          $i++;
          mysql_query($sql);
          }





          share|improve this answer























          • Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
            – Eduardo
            Jan 29 '13 at 16:31












          • @Eduardo What do you mean by do not know what to do? What kind of help do you need?
            – Antony
            Jan 29 '13 at 16:32













          up vote
          0
          down vote










          up vote
          0
          down vote









          $connect = mysql_connect('localhost','root','');
          if(!$connect)
          {
          die('Could not connect:' . mysql_error());
          }
          mysql_select_db('test',$connect);


          // txt file

          $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

          $i = 0;

          while ( ($line = fgets($file)) !== false) {

          // get the email <email@email.com>
          if (preg_match('/<(.+)>/', $line, $email)) {
          $coincidencias = $email[1];
          }
          if (strlen(trim($line)) > 0) {
          $still_empty = false;
          $content[$i] .= preg_replace('/<.+>: /', '', $line);
          } else {
          if (!$still_empty) {
          $i++;
          }
          $still_empty = true;
          }
          }

          $i = 0;
          foreach ($coincidencias as $email)
          {
          // create a query and insert into database
          $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."','".$content[$i]."',now());";
          echo '<pre>'.$sql.'</pre>';
          $i++;
          mysql_query($sql);
          }





          share|improve this answer














          $connect = mysql_connect('localhost','root','');
          if(!$connect)
          {
          die('Could not connect:' . mysql_error());
          }
          mysql_select_db('test',$connect);


          // txt file

          $file = fopen("email_errors.txt", "r") or exit ("Unable to open file");

          $i = 0;

          while ( ($line = fgets($file)) !== false) {

          // get the email <email@email.com>
          if (preg_match('/<(.+)>/', $line, $email)) {
          $coincidencias = $email[1];
          }
          if (strlen(trim($line)) > 0) {
          $still_empty = false;
          $content[$i] .= preg_replace('/<.+>: /', '', $line);
          } else {
          if (!$still_empty) {
          $i++;
          }
          $still_empty = true;
          }
          }

          $i = 0;
          foreach ($coincidencias as $email)
          {
          // create a query and insert into database
          $sql = "INSERT INTO errormailer(id_error, email, description, fecha) VALUES(NULL,'".$email."','".$content[$i]."',now());";
          echo '<pre>'.$sql.'</pre>';
          $i++;
          mysql_query($sql);
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 29 '13 at 16:18

























          answered Jan 29 '13 at 16:12









          Antony

          13k103667




          13k103667












          • Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
            – Eduardo
            Jan 29 '13 at 16:31












          • @Eduardo What do you mean by do not know what to do? What kind of help do you need?
            – Antony
            Jan 29 '13 at 16:32


















          • Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
            – Eduardo
            Jan 29 '13 at 16:31












          • @Eduardo What do you mean by do not know what to do? What kind of help do you need?
            – Antony
            Jan 29 '13 at 16:32
















          Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
          – Eduardo
          Jan 29 '13 at 16:31






          Thanks for your help, and do not know what to do. php display notice,Notice: Undefined offset: 0 in upload.php on line 29. I'm checking
          – Eduardo
          Jan 29 '13 at 16:31














          @Eduardo What do you mean by do not know what to do? What kind of help do you need?
          – Antony
          Jan 29 '13 at 16:32




          @Eduardo What do you mean by do not know what to do? What kind of help do you need?
          – Antony
          Jan 29 '13 at 16:32


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14585379%2fretrieve-variables-in-a-txt-of-multiple-values-in-php%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          List item for chat from Array inside array React Native

          Thiostrepton

          Caerphilly