Hi,
I seem i seem to have a problem with this:[PHP]
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?
7 1933
Hi,
I seem i seem to have a problem with this:
[PHP]
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?
HI
assign reg expression value to $email_match_regex
Hi,
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
Hey there adam!
PHP is saying you haven't got a variable named email_match_regex?
Check to see if you do!
Regards.
Hi Adam,
The problem is in the follwoing line:
[PHP]$content = file_get_contents('http://www.web.co.uk/d.asp?ID='.$i);[/PHP]file_get_contents() will fetch raw data, ie the page will not be parsed.
And becasuse its not parsed, the filename param given must match to the filename exactly.
Consequently, because $content is empty, you get a whole load of problem further down your script.
My question to you: should you be trying to take data from other websites?
Hi Adam,
The problem is in the follwoing line:
[PHP]$content = file_get_contents('http://www.web.co.uk/d.asp?ID='.$i);[/PHP]
file_get_contents() will fetch raw data, ie the page will not be parsed. And becasuse its not parsed, the filename param given must match to the filename exactly.
Consequently, because $content is empty, you get a whole load of problem further down your script.
My question to you: should you be trying to take data from other websites?
This is absolutely not true!
The error originates in the absence of the regular expression pattern variable in line 11. Since there is no result, there is also no $matches variable, resulting in the error on line 13.
The content of variable $content has nothing to do with this. Even if it is empty the preg_match_all results in an array containing one or more empty arrays.
My question to you: should you be trying to take data from other websites?
And please: no missionaries. This is not the place to question our members on their reason for using a pretty-standard PHP function. There is no indication whatsoever that it is morally unjust or illegal what our member adamjblakey is doing! So don't even hint at that!
Ronald
Thank you for that ronverdonk, i have now done this based on your comments, which does not bring any errors back but does not bring any results but i know there should be.
[PHP]<?php
$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/details.asp?ID='.$i);
preg_match_all($email_match_regex, $content, $matches);
foreach($matches[1] as $index => $value) {
print $index[1];
}
}
?>[/PHP]
Please explain what the reg exp is supposed to filter.
Ronald
There will be one email per id and they like this: - <a href="mailto:adam@email.com?Subject=This is the sbject of the email (Company-Name)&Body=Referral from www.web.co.uk%0D%0A%0D%0A" title="Send e-mail to company name">
I just need the email address e.g.: adam@email.com Sign in to post your reply or Sign up for a free account.
Similar topics
by: Han |
last post by:
I'm wondering if someone can explain why the following works with
preg_match_all, but not preg_match:
$html = "product=3456789&"
preg_match_all ("|product=(\d{5,10})&|i", $html, $out);
$out...
|
by: Han |
last post by:
I know this is possible (because preg can do almost anything!), but can't
get a handle on the syntax.
I have an HTML string:
<font size="3"><a...
|
by: Han |
last post by:
Using preg_match_all, I need to capture a list of first and last names plus
an optional country code proceeding them.
For example:
<tr><td>AU</td><td>Jane Smith</td></tr>...
|
by: Han |
last post by:
The following pattern (which is one subpattern in a string of several) looks
for the following
$xxx,xxx.xx (with the dollar sign)
or
xxx,xxx.xx (space in replace of missing dollar sign)
...
|
by: petrovitch |
last post by:
While using the following loop to extract images from the google search
engine I discovered that preg_match_all works much faster parsing small
strings in a loop than extracting all of the urls at...
|
by: Fabian |
last post by:
Hi all there,
I have already tried asking for help a couple of days ago.
I try to rephrase better my problem:
I need to grab a webpage that looks like this:
<td width=80 align=center...
|
by: greatprovider |
last post by:
i'm starting with a string such as "Na**3C**6H**5O**7*2H**20"
im attempting to match all **\d+ ...once i can match all the double
asterix \d i intend to wrap the \d in "<sub>" tags for display...
|
by: tommybiegs |
last post by:
I'm reluctant to post a bug report on php.net because they're so
vicious with bogus reports, so I thought I'd check here to make sure
I'm not going crazy:
<?php
$string = "Hello/", $string,...
|
by: Anthony Smith |
last post by:
I am trying to take a web page and get all of the links. It almost
works, but I am missing a few links.
Here is what I am using.
preg_match_all('/href=?(*)?*>(.*?)<\/a>/i',...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |