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;