Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    Lost connection to MySQL server during query error

    Hi guys..

    I have two database, one has 17000 numbers and the other one has only 3 numbers..

    When i run the script below using the database with 17000 numbers i get this error "Lost connection to MySQL server during query"

    and when i run the script with the the database that has only 3 numbers in it.. the script works perfect...

    PHP Code:
        $config['dbhost'] = 'hostname';
        
    $config['dbuser'] = 'kevin';
        
    $config['dbpass'] = 'password';
        
    $config['dbname'] = 'database with 1700 numbers';
        

        
    //$config['dbhost'] = 'mysql359int.cp.blacknight.com';
        //$config['dbuser'] = 'u1001236_test';
        //$config['dbpass'] = 'password';
        //$config['dbname'] = 'db1001236_testing';

        
    set_time_limit(0);
        
        
    ini_set('error_reporting'E_ALL);

         
    error_reporting(E_ERROR E_WARNING E_PARSE);

        
    //define the base path for the files
        
    $maindir dirname(__FILE__) . DIRECTORY_SEPARATOR;


        
    //connect to the databse server and select database.
        
    @mysql_connect($config['dbhost'], $config['dbuser'], $config['dbpass']) or die(mysql_error());
        @
    mysql_select_db($config['dbname']) or die(mysql_error());


        
    $sql "SELECT * FROM `phone_number` WHERE `phone` NOT IN (SELECT `phone` FROM `phone_number_sent`)";
        
    $rea = @mysql_query($sql) or die(mysql_error());

        
    //define phone list array
        
    $phone_list = array();
      
    // rsa = record set array
        
    while ($rsa=mysql_fetch_array($rea)) {
            
            echo 
    $rsa['phone']."<br />";
            
    //$phone_list[] = array($rsa['phone'], $rsa['source']);
        

    Does any body know what the problem might be?
    Last edited by kevinkhan; 03-29-2010 at 01:31 PM.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,474
    Thanks
    13
    Thanked 361 Times in 357 Posts
    I’d hazard a guess at timing out.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    What do you mean exactly..

    how would i go about fixing this? and is there a way i can improve my code to get it to work?

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,474
    Thanks
    13
    Thanked 361 Times in 357 Posts
    Quote Originally Posted by kevinkhan View Post
    What do you mean exactly..
    there is a time limit for a PHP script (to prevent inifinite loops blocking the interpreter)

    Quote Originally Posted by kevinkhan View Post
    how would i go about fixing this? and is there a way i can improve my code to get it to work?
    I’d go for SQL optimization, best ask in the SQL forum.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by kevinkhan View Post
    When i run the script below using the database with 17000 numbers i get this error "Lost connection to MySQL server during query"
    Did you check Google?
    http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
    Are you a Help Vampire?

  • #6
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Increase mysql connection time out in php.ini, variable is mysql.connect_timeout.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •