Codeigniter lists Incorrect email addresses

Source: Internet
Author: User
Tags php foreach codeigniter
Hello everyone, I used CodeIgniterPHPforeach to go through an email address form and found some emails that do not meet the requirements of regular expressions. The difficulty lies in the difficulty of listing results in the form of objects. Code: PHP: {code ...} HTMLSignup_test_view... hello everyone, I used CodeIgniter PHP foreach to go through an email address form and found some emails that do not meet the requirements of regular expressions.

The difficulty lies in the difficulty of listing results in the form of objects.

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; ?>

Error message:

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

But I have already used the following line of code to convert an array into an object:

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

Thank you!

Update:

Some people suggest changing the code in the view

  
    
  email; ?>

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 used CodeIgniter PHP foreach to go through an email address form and found some emails that do not meet the requirements of regular expressions.

The difficulty lies in the difficulty of listing results in the form of objects.

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; ?>

Error message:

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

But I have already used the following line of code to convert an array into an object:

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

Thank you!

Update:

Some people suggest changing the code in the view

  
    
  email; ?>

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 very useful, so you need to convert an array into an object?

$ Obj = (object) $ array;

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.