Jump to content

I Need Help With my script


factoring2117

Recommended Posts

Hello everyone,

 

I am fairly new to php and I seem to have run into a problem while writing a script.  The script is designed to pull data from profiles on myspace. The part of the script that I am writing now checks for certain keywords on the page. If the certain keywords exist, the user should not be able to add their profile to the page.

 

The problem I am running into is that I am using the while function and I believe I should be using something else. The reason for this is because there are 10 keywords I am checking for, so the script runs 10 times because I am using while.

 

Here is my code:

 

<?php

include('config.php');
$target_url = "http://www.example.com/1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$html = curl_exec($ch);


$select = mysql_query("SELECT * FROM newBan");
while($row = mysql_fetch_array($select)) {

if(preg_match("/".$key."/i", $html)) {

echo "<p>Sorry you cannot add this profile.</p>";

} else  {
     
 echo "The rest of the script continues.";		

}
}

?>

 

 

Is there a better method other than using while?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/140317-i-need-help-with-my-script/
Share on other sites

I don't understand what you mean by adding all the keys into one strong. So I should still use the while function?

 

This is what I tried below, but the array only shows the last keyword in the list.

 

Please help.

 

<?php

include('config.php');
$target_url = "http://www.example.com/1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$html = curl_exec($ch);


$select = mysql_query("SELECT * FROM newBan");
while($row = mysql_fetch_assoc($select)) {

$key = array($row['keyword']);

$key1 = $key[0];
$key2 = $key[1];

}

echo "$key1<br /> $key2";

if(preg_match("/".$key."/i", $html)) {

echo "<p>Sorry you cannot add this profile.</p>";

} else  {
     
 echo "The rest of the script continues.";		

}


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.