Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:02:36+00:00 2026-06-16T04:02:36+00:00

I have a list of url’s(link) in my database and can echo the data

  • 0

I have a list of url’s(link) in my database and can echo the data to the page fine but instead of outputting it, I need to store that info(I was thinking an array) into a variable to perform php tasks using the provided links. I have yet to figure out how to do this.

The code has been updated I removed any references to using the soon to be deprecated mysql_* functions and opted for the mysqli version.

Heres my code

$query = "SELECT `Link` FROM `Table1` WHERE `Image` ='' AND `Source`='blah'";

if ($result = mysqli_query($dblink, $query)) {

while ($row = mysqli_fetch_assoc($result)) {  
    $link = $row['Link'];
    // echo ''.$link.'<br>';
        $html = file_get_html($link);
        foreach ($html->find('div.article') as $e) {
            $result = $e->find('img', 0);
            $imgsrc = $result->src . '<br>';
            echo $imgsrc;
        }
    }
}

This code is working through one iteration: It will find the first link stored in the DB, use that $link in the bottom foreach() statement and output the desired result. After the first iteration of the loop, an error occurs stating:

“mysqli_fetch_assoc() expects parameter 1 to be a mysql result”

I think I understand why the problem is occurring – Since the $result is declared outside of the while loop, it is never set again after the first iteration/or changes in some way.

or

I should be using mysqli_free_result() possibly, If that were the case I am not sure where it would go in the code.

Thanks for any help you can offer!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:02:37+00:00Added an answer on June 16, 2026 at 4:02 am

    When you do this:

    $result = mysqli_query($dblink, $query);
    

    The functions return a link identifier you store in $result. This identifier we need to pass to fetch functions in order to be able to show it from which result to fetch. It shouldn’t be changed until you are done fetching all the results you want.

    This goes right the first time:

    $row = mysqli_fetch_assoc($result)
    

    But then, in the foreach, you overwrite that variable with other information:

    $result = $e->find('img', 0);
    

    As such, when the next iteration comes around, it is no longer a valid result identifier, so MySQL doesn’t know what to do with it.

    The fix is actually rather simple, you need to change the name of the variable you are using in the foreach:

    $result = $e->find('img', 0);
    $imgsrc = $result->src . '<br>';
    

    Becomes:

    $found= $e->find('img', 0);
    $imgsrc = $found->src . '<br>';
    

    And voila, it should work…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list that I need to send through a URL to a
i have a list of url's that i want to save but they are
I have a list of url data in a file that looks like this:
I have data in text file and I need to store it in database
I have a list of Url in file url.data like this http://site1.org/info.php http://site2.com/info/index.php http://site3.edu/
I have a asp.net page where i query a list of url and the
I have a script that pulls in meta data from a list of URL's
I have a list of URLs and need to load each page, one after
I have a URL list of jar files, also I have whole path classname
I have big URL list, which I have to download in parallel and check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.