Hi, I seem i seem to have a problem with this: for($i=1;$i<7;$i++) { $content = file_get_contents('http://www.web.co.uk/d.asp?ID='.$i); preg_match_all($email_match_regex, $content, $matches); foreach($matches[1] as $index => $value) { print $index[1]; } } PHP: I am getting the following errors which i cannot fix: Warning: Invalid argument supplied for foreach() in /home/ee/public_html/test.php on line 13 Notice: Undefined variable: email_match_regex in /home/ee/public_html/test.php on line 11 Any Ideas?
You haven't defined a regex pattern to validate emails $email_match_regex = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; for($i=1;$i<7;$i++) { $content = file_get_contents('http://www.web.co.uk/d.asp?ID='.$i); preg_match_all($email_match_regex, $content, $matches); foreach($matches[1] as $index => $value) { print $index[1]; } } PHP:
Thank you for your reply but i am now getting this error: Warning: preg_match_all() [function.preg-match-all]: No ending delimiter '^' found in /home/ee/public_html/test.php on line 16 Warning: Invalid argument supplied for foreach() in /home/ee/public_html/test.php on line 18 I though the problem might be with the $email_match_regex so i did this: $email_match_regex = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$^"; But this then does not give any errors or results and goes to a white screen.
I'm not that good with regex lets wait for someone else to post a better pattern. are you trying to fetch data from http://www.web.co.uk/d.asp?ID=1 because this webpage does not exists
Notice: Undefined variable: email_match_regex in /home/ee/public_html/test.php on line 11 What that basically means is that the PHP script is searching for the content files and not finding anything useful. So there's nothing to replace therefore it's nulled. some sites don't allow the retrieval through php. I know from experience.