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

  • SEARCH
  • Home
  • 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 8628479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:33:20+00:00 2026-06-12T08:33:20+00:00

I collect data from a website that, sometimes, seems to be not accessible (or,

  • 0

I collect data from a website that, sometimes, seems to be not accessible (or, maybe it’s just the DNS host that has sometimes some issues).
The program written in PHP (launched with CLI) quits with the error:

Couldn’t resolve host ‘abcdef.com’

I would like to intercept this error, like with an exception, because the program must not quit.

I tried a “try catch” but this doesn’t work.

I would like to avoid the use of an external daemon to restart the program…

Thank you for your help.

EDIT :
The code used :

function goToPage($url) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_COOKIEFILE, realpath("./cookies/cookie.txt"));
        $ret = curl_exec($ch);
        if ($ret === FALSE) {
            die(curl_error($ch));
        }
        curl_close($ch);

        $this->delay();

        return $ret;
}
  • 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-12T08:33:22+00:00Added an answer on June 12, 2026 at 8:33 am

    Are you sure that it is actually stopping the execution of your program? I mean, if it’s not an Exception… it’s not an Exception. As far as I know, cURL doesn’t throw any Exceptions or fatal errors. What you’re seeing is most likely just a regular notice / warning. To figure out whether or not you have cURL errors, you can just use the functions curl_errno() and curl_error():

    if(curl_errno($ch))
    {
        echo 'error:' . curl_error($ch);
    }
    

    Or, if you want to throw a custom Exception:

    //you'll probably want to customize this further based on the type of error.
    if(curl_errno($ch)){
        throw new Exception( curl_error($ch) );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to collect some data from the front page of a website. I
I am building an ASP.NET website which will collect data from a user and
I am trying to collect some data from multiple subsets of a data set
I have the following situation: I have an application that collects some data from
I am delivering a module for a website that will collect information from a
How to collect data from inputs (inputs are in table which has id=tbl_bbmd and
I have a custom workflow that uses the Collect data from a user action,
I have a script that follows that is supposed to collect data from a
I'm thinking about making an app that gets data from a website. However this
I'm am writing a bit of python code that gets data from a website.

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.