php help, searching strings

Status
Not open for further replies.

Russ

<b>Retired *****</b>
Messages
3,168
Reaction score
2
Points
38
I have this script, basically what it is to do, is connect to a database, get all of the URLs out of a table, and check them for a string, if it finds it say so, if not say it didn't.. it connects to the db alright, but its returning them all as not found, although I know it is on one of the pages it's searching.. heres the code:

PHP:
<?

echo "<b>Users found:</b><br> ";
mysql_connect("localhost", "8888888888", "8888888888888");
mysql_select_db("888888888888");
$result =  mysql_query("SELECT * FROM `ebp_ad` LIMIT 0, 30 ");
while($row = mysql_fetch_array($result)){

file_get_contents($row[url]);

if (preg_match("/^tufat.com/", '$data')) {
    echo "A match was found." .$row[url]. "<br>";
} else {
    echo "A match was not found." .$row[url]. "<br>";
} 
}
?>

Basically, its suppose to search for tufat.com..
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Not only is $data not defined anywhere in that code, but you have it enclosed in single quotes which means it won't be evaluated to its string value. Did you mean to set $data to the result of file_get_contents()?
 

Russ

<b>Retired *****</b>
Messages
3,168
Reaction score
2
Points
38
yes, I did.. code modified to
$data = file_get_contents($row); if (preg_match("/^tufat.com/", ... tufat.com on the pages, and I know its there
 
Last edited:
Status
Not open for further replies.
Top