Variable passed to each() is not an array or object


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

This is a email a friend type of form, and it isn't working anymore.

<?

function validate_email($email, $location) {
$valid_address = true;

$mail_pat = '^(.+)@(.+)$';
$valid_chars = "[^] ()<>@,;:.\"[]";
$atom = "$valid_chars+";
$quoted_user='("[^"]*")';
$word = "($atom|$quoted_user)";
$user_pat = "^$word(.$word)*$";
$ip_domain_pat='^[([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})]$';
$domain_pat = "^$atom(.$atom)*$";

if (eregi($mail_pat, $email, $components)) {
$user = $components[1];
$domain = $components[2];
// validate user
if (eregi($user_pat, $user)) {
// validate domain
if (eregi($ip_domain_pat, $domain, $ip_components)) {
// this is an IP address
for ($i=1;$i<=4;$i++) {
if ($ip_components[$i] > 255) {
$valid_address = false;
break;
}
}
}
else {
// Domain is a name, not an IP
if (eregi($domain_pat, $domain)) {
/* domain name seems valid, but now make sure that it ends in a valid TLD or ccTLD
and that there's a hostname preceding the domain or country. */
$domain_components = explode(".", $domain);
// Make sure there's a host name preceding the domain.
if (sizeof($domain_components) < 2) {
$valid_address = false;
} else {
$top_level_domain = strtolower($domain_components[sizeof($domain_components)-1]);
// Allow all 2-letter TLDs (ccTLDs)
if (eregi('^[a-z][a-z]$', $top_level_domain) != 1) {
$tld_pattern = '';
// Get authorized TLDs from text file
$file_t = $location . "functions/tld.txt";
$tlds = file($file_t);
while (list(,$line) = each($tlds)) {
// Get rid of comments
$words = explode('#', $line);
$tld = trim($words[0]);
// TLDs should be 3 letters or more
if (eregi('^[a-z]{3,}$', $tld) == 1) {
$tld_pattern .= '^' . $tld . '$|';
}
}
// Remove last '|'
$tld_pattern = substr($tld_pattern, 0, -1);
if (eregi("$tld_pattern", $top_level_domain) == 0) {
$valid_address = false;
}
}
}
}
else {
$valid_address = false;
}
}
}
else {
$valid_address = false;
}
}
else {
$valid_address = false;
}
if ($valid_address && ENTRY_EMAIL_ADDRESS_CHECK == 'true') {
if (!checkdnsrr($domain, "MX") && !checkdnsrr($domain, "A")) {
$valid_address = false;
}
}
return $valid_address;
}

?>

These are the errors I get:

Warning: failed to open stream: No such file or directory on line 46

Warning: Variable passed to each() is not an array or object on line 47

Warning: eregi() [function.eregi]: REG_EMPTY on line 58

Could someone please help me.

Thank you

No comments posted yet

Your Answer:

Login to answer
140 Like 5 Dislike
Previous forums Next forums
Other forums

How to pass parameter to tag query?
Hi,
I want to get the value of a tag at a specific time (like 10/27/09 15:29:59), I need to giv

header redirect problems? please help
Ok i am making a site that generates youtube thumbnails and i am generating an image that displays 1

what business processes?
Hi,

A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

how to use two buttons with php
hi i have one form. there are three fields which are to be filled by the user. and then there are tw

Function
How can I make this function that once you click the link in the code it takes you to a new page wit

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

Unexpected T_Variable ?
Hi all,
I dont really know what I am doing!! I know I'm doing something wrong, and I know its on

php is not recognized as an internal or external command
Hello,

I am trying to bake the code in CakePHP through my console.
I have changed my Path

Pls help with PHP
Pls can anyone direct me on how to create a user account for a customer. For example i want know if

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash