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;