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 4088060
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:56:03+00:00 2026-05-20T18:56:03+00:00

I have a CLI script which when you first start it: function __construct(){$this->connectToDatabase();} protected

  • 0

I have a CLI script which when you first start it:

function __construct(){$this->connectToDatabase();}
protected function connectToDatabase(){
    try{
        $this->databaseName = $this->dbname;
        $this->posName = $this->posName;
        $this->vlog = $this->vlogName;
        $this->database = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
        mysql_select_db($this->databaseName, $this->database);
    }
    catch(Exception $e){
        $this->console($e);
    }
}

This CLI script can stay running for days. How do i keep the mysql connection open? or before each mysql_query do i have to check if the connection is still open?

This is the error im getting:

MySQL Error: MySQL server has gone away

  • 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-05-20T18:56:03+00:00Added an answer on May 20, 2026 at 6:56 pm

    Check this : https://www.digitalocean.com/community/questions/how-to-set-no-timeout-to-mysql

    In particular, it is stated:

    The server timed out and closed the
    connection. By default, the server
    closes the connection after 8 hours or
    28800 seconds if nothing has happened.
    You can change the time limit by
    setting the wait_timeout variable when
    you start mysqld via your server’s
    /etc/my.cnf […]

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

Sidebar

Related Questions

I have developed a application which caches multiple packages. The CLI interface for this
I have a PHP CLI script ( http://codepad.org/w6iyLLdv ) which stubbornly returns exit code
I currently have a PHP CLI script using Zend Framework extensively which seems to
Hi guys I have a weird question, I have a cli php script runs
I have a php script that is running in CLI and I want to
I have a cli application that doesn't like the usage of wildcards. In this
I have a C++/CLI based install application which needs to close another app I've
Im using Debian testing, i have installed php-cli and when i try to execute
I have a GUI app written in C++/CLI which has a load of configurable
The Disclaimer First of all, I know this question (or close variations) have been

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.