[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

01/18/2009 at 09:54AM PST, ID: 24062042
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.5

PHP

Asked by chrisj1963 in PHP Scripting Language

Hi.
this code is getting the following error:

Notice: Undefined variable: keyword in /home/g3crmco/public_html/deny-ray.php on line 183
and
Notice: Undefined variable: count in /home/g3crmco/public_html/deny-ray.php on line 163

see example here:

http://70.87.107.194/~g3crmco/deny-ray.php?keyword=good+lawyer&url=http%3A%2F%2F70.87.107.194%2F~g3crmco%2Fsamplepage.htm&Submit=Submit

I am not clear about how to solve this problem with the variable and would appreciate some guidance.

thanks,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
<?php
error_reporting(E_ALL);
//prevents script from timing out
set_time_limit(0);
 
 
 
 
//for POST request with curl
function do_post_request_curl($url, $data)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
    curl_setopt($ch, CURLOPT_POST, 1); // set POST method
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // add POST fields
    $result = curl_exec($ch); // run the whole process
    //echo $result;
    curl_close($ch);
    return $result;
}
 
function file_get_contents_curl($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    curl_close($ch);
 
    return $data;
}
function getUrl ($sel_keyword) {
	$arrLinks=array();
	$cnt=0;
 
 	$url = 'http://www.google.com/search?hl=en&q='.urlencode($sel_keyword).'&btnG=Google+Search&aq=f&oq=';
	$str = "'".file_get_contents($url)."'";
 
    $h1count = preg_match_all('/\<li class=g\>\<h3 class=r\>\<a href="(.*?)" class=l\>/',$str,$patterns);
 
    $href_add = $patterns[1];
 
 
    if(!empty($href_add[0]))
    {
        foreach($href_add as $key => $val)
        {
        $val = preg_replace("/</","&lt;a",$val);
            //echo "<li>" . htmlentities($val) . "</li>";
            $arrLinks[$cnt]=htmlentities($val);
            ++$cnt;
			//number of urls code CJ
            if($cnt==1)
            {
				break;
            }
 
        }
        echo "</ul>";
    }
	return $arrLinks;
}
?>
 
 
 
 
 
<!--<?php include('includes/header.php');?>-->
 
<body>
<form id="form1" name="form1" method="get" action="">
  KEYWORD:
	<input name="keyword" type="text" id="keyword" value="<?php echo $_REQUEST['keyword']; ?>" />
  URL :
  	<input name="url" type="text" size="30" id="url" value="<?php echo $_REQUEST['url']; ?>" />
  	<input type="submit" name="Submit" value="Submit" />
  	<br>
  <br>
</form>
<?php
	if ((isset($_REQUEST['Submit'])) && ($_REQUEST['url']!='')) {
?>
<fieldset>
<legend>Query result</legend>
<?php
	$urlarray = array();
 
	$urlarray[0]=$_REQUEST['url'];
 
 
	$arrLinks=getUrl($_REQUEST['keyword']);
 
	for($i=0,$j=1;$i<count($arrLinks);$i++,$j++){
		$urlarray[$j]=$arrLinks[$i];
	}
 
 
?>
 
<table border=1 width="80%">
	<tr>
		<th>Link</th>
		<th>Item #1</th>
  </tr>
<?php for($i=0;$i<count($urlarray);$i++){
// wait for 5 seconds = 5,000,000  HUMAN EMULATION
//usleep(5000000);
 
//Have a bit of a rest before we go check the next keyword  3-6 seconds
sleep(rand(2,3));
?>
	<tr>
		<td>
			<?php
			if($i==0){
			?>
				<a href="<?php echo $urlarray[$i];?>" style="color:blue"><?php echo $urlarray[$i];?></a>
			<?php
			}
			else{
			?>
				<a href="<?php echo $urlarray[$i];?>"><?php echo $urlarray[$i];?></a>
			<?php
			}
			?>        </td>
	<?php
 
 
ob_start();
 
//put your site's URL here, but leave off the http://www
//$url = "windmillaeration.com";
 
//put all the keywords you want to check here, make sure you leave the single quotes and commas intact for each keyword
//$keywords = array(
//'"pond aeration"',
//'windmill aeration',
//'windmill',
// );
 
//Just tells us what URL we're checking rankings for
//echo "<h2> Google SERPS For " .$url. "</h2>";
 
//start to run through each of the keywords
//foreach($keywords as $keyword)  {
 
//set our counter at zero, so we can work out what the ranking of the page
//$count = 0;
 
//make a URL that we can query Google with
$search = "http://www.google.com/search?q=".$urlarray[$i]."&num=100";
//now go get that page
$google = file_get_contents($search);
 
//funky regular expression stuff to find our URL in the results
$description= ('/<h3 class=r><a href=\"(.+?)\" class=l/');
preg_match_all($description,$google,$match);
 
//start looping through each of the results on the page
foreach( $match[1] as $value){
$count = $count + 1;
 
//check each of the 100 results from google, to see if our URL is in it.
if(strstr($value,$urlarray[$i])) {
 
//if this particular result has our URL in it, print it to the page, along with the ranking ($count variable from above)
//echo $keyword. " - " .$count. "<br>";
ob_flush();
flush();
}
}
//Have a bit of a rest before we go check the next keyword, so we don't get booted from the Goog'
sleep(rand(30,60));
}
 
?>
 
 
 
 
 				<td><?php echo $keyword. " - " .$count;?></td>
	</tr>
 
<?php } ?>
</table>
 
</fieldset>
	</body>
<!--<?php include('includes/footer.php'); ?>-->
</html>
[+][-]01/18/09 09:58 AM, ID: 23405750

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/18/09 10:00 AM, ID: 23405755

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/18/09 10:32 AM, ID: 23405870

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01/18/09 11:49 PM, ID: 23408792

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/19/09 08:10 AM, ID: 23411826

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/19/09 11:54 AM, ID: 23413874

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/19/09 05:14 PM, ID: 23416411

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Sign Up Now!
Solution Provided By: Ray_Paseur
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625