Jump to content

Fatal error: Cannot redeclare getPage()


pioneerx01

Recommended Posts

I know what is wrong but I have no idea how to fix it. This code (at lease part of it) should loop about 17 times (based on the current parameters in the database), but it stops after 1st. I have no idea how to "undeclare" getPage() at the end to make it loop again.

 


$result = mysql_query("SELECT * FROM Teacher_Registrations WHERE active ='Yes' Order by Full_Name");
while($row = mysql_fetch_array($result)) {
$result2 = mysql_query("SELECT * FROM Project_Registrations WHERE (Teacher = '$row[Full_Name]') AND ((Paid_1 = 'No') OR (Paid_2 = 'No' AND Second_Name != 'nostudent') OR (Paid_3 = 'No' AND Third_Name != 'nostudent'))");
$num_rows2 = mysql_num_rows($result2);
$row2 = mysql_fetch_array($result2);
	if ($num_rows2 > '0') {

$url = 'http://www.mayapge.us/page.php?';
$url .= 'email='.urlencode("myemail");
$url .= '&teacherid='.urlencode($row['ID']);

function getPage($proxy, $url, $header, $timeout) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_REFERER, 'http://mypage.org');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0. Gecko/2009032609 Firefox/3.0.8');
    $result3['EXE'] = curl_exec($ch);
    $result3['INF'] = curl_getinfo($ch);
    $result3['ERR'] = curl_error($ch);
    curl_close($ch);
    return $result3;
}
$result3 = getPage('', $url, '', 15);

}}

Link to comment
https://forums.phpfreaks.com/topic/229218-fatal-error-cannot-redeclare-getpage/
Share on other sites

I need to use all the code in loop every loop. I have tried requiring (and including) the entire function from external page, but still same error. How would I take this entire code and define it as a function outside the loop?

&thisfunction = {thecode};

 

$url = 'http://www.mayapge.us/page.php?';
$url .= 'email='.urlencode("myemail");
$url .= '&teacherid='.urlencode($row['ID']);

function getPage($proxy, $url, $header, $timeout) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_REFERER, 'http://mypage.org');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0. Gecko/2009032609 Firefox/3.0.8');
    $result3['EXE'] = curl_exec($ch);
    $result3['INF'] = curl_getinfo($ch);
    $result3['ERR'] = curl_error($ch);
    curl_close($ch);
    return $result3;
}
$result3 = getPage('', $url, '', 15);

 

 

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.