I'm using code (http://code.google.com/p/phpquery/) to scrap html from one of my own sites

$response = file_get_contents("$html2", false, $context);
$doc = phpQuery::newDocument($response);
$div = $doc->find(".home-container");

foreach($doc->find('.table-td') as $article){
    $article = pq($article);

here is a snippet of code, when I run the page by itself it's fine and works. However, the page i'm getting this from us dynamic. mypage.php?News=12. So if I call this page it's good.

I have a custom page how were I'm doing a news search looking for ID's for today. Today, for example, I have 10, I want to look through these and require this phpquery page 10 times. However when I do I get this error...

Fatal error: Cannot redeclare pq() (previously declared in C:\wamp64\www\mysite\phpQuery.php:1324)

why and how can i fix this?

Just a guess, but maybe you need to do a require_once instead of a require somewhere (or include_once instead of include) so that you don't try to define that function more than once?

    NZ_Kiwis Fatal error: Cannot redeclare pq() (previously declared in C:\wamp64\www\mysite\phpQuery.php:1324)

    On what line is the error reported?

    NZ_Kiwis from one of my own sites

    I suppose there would be a need for this...

      NZ_Kiwis I want to look through these and require this phpquery page 10 times

      My eyes missed this first time through -- sounds like it's definitely because you're requiring a file that includes a function definition (at least of function pq()), and PHP won't let you re-use that function's name when you try to define it again. Solutions would include moving function definitions to a separate file that you could require_once(), or wrapping the function definition in an if() block leveraging the function_exists() test -- but that latter option is pretty ugly, IMHO.

        Write a Reply...