CodeIgniter list the wrong email address

Source: Internet
Author: User
Tags php error php foreach codeigniter
Hello everyone, I am using CodeIgniter PHP foreach email address form, found some non-conforming to the regular expression requirements of the email, listed for improvement.

The challenge is that it is difficult to list the results in object form.

Code:

Php:

    $this->db->where('status', 'subscribed');    $email_preliminary=$this->db->select('email')->get('user');     $email_raw = array();    foreach ($email_preliminary->result() as $row):        $email_to_test=$row->email;        if(filter_var($email_to_test, FILTER_VALIDATE_EMAIL)||preg_match('/\d*[1-9]\d*/', $email_to_test))        {            $email_raw[] = $email_to_test;        }        else{        }    endforeach;    $record_raw=array_unique($email_raw);    $data['record'] = json_decode (json_encode ($record_raw), FALSE);    $this->load->view('login&signup/signup_test_view', $data);}

In HTML Signup_test_view, I have:

  
  
   result() as $row): ?>
   
    email; ?>

The error message is:

Call to a member function result () on a non-object in d:\views\login&signup\signup_test_view.php

But I'm not already using this line of code to convert an array into an object:

  $data['record'] = json_decode (json_encode ($record_raw), FALSE);

Thank you!

Update:

Some students suggest to change the code in the view into

  
  
     
   
    email; ?>

Also tried, the error message is still:
A PHP Error was encountered

Severity:notice

Message:trying to get property of Non-object

filename:login&signup/signup_test_get_wrong_email_view.php

Reply content:

Hello everyone, I am using CodeIgniter PHP foreach email address form, found some non-conforming to the regular expression requirements of the email, listed for improvement.

The challenge is that it is difficult to list the results in object form.

Code:

Php:

    $this->db->where('status', 'subscribed');    $email_preliminary=$this->db->select('email')->get('user');     $email_raw = array();    foreach ($email_preliminary->result() as $row):        $email_to_test=$row->email;        if(filter_var($email_to_test, FILTER_VALIDATE_EMAIL)||preg_match('/\d*[1-9]\d*/', $email_to_test))        {            $email_raw[] = $email_to_test;        }        else{        }    endforeach;    $record_raw=array_unique($email_raw);    $data['record'] = json_decode (json_encode ($record_raw), FALSE);    $this->load->view('login&signup/signup_test_view', $data);}

In HTML Signup_test_view, I have:

  
  
   result() as $row): ?>
   
    email; ?>

The error message is:

Call to a member function result () on a non-object in d:\views\login&signup\signup_test_view.php

But I'm not already using this line of code to convert an array into an object:

  $data['record'] = json_decode (json_encode ($record_raw), FALSE);

Thank you!

Update:

Some students suggest to change the code in the view into

  
  
     
   
    email; ?>

Also tried, the error message is still:
A PHP Error was encountered

Severity:notice

Message:trying to get property of Non-object

filename:login&signup/signup_test_get_wrong_email_view.php

Array is not a good use, then you need an array to convert to object?

$obj = (object) $array;

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.