CodeIgniter Forums
MySQL Connection Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: MySQL Connection Problem (/thread-22326.html)



MySQL Connection Problem - El Forum - 09-05-2009

[eluser]Mareshal[/eluser]
I've uploaded my site on a host and I get this error:

Quote:ERROR - 05-09-2009 16:39:43 --&gt; Severity: Warning --&gt; mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 /home/******/public_html/elite/system/database/drivers/mysql/mysql_driver.php 70
ERROR - 05-09-2009 16:39:43 --&gt; Unable to connect to the database

database details are 100% correct

here is database.php
Code:
$active_group = "elite";
$active_record = TRUE;

$db['elite']['hostname'] = "*******";
$db['elite']['username'] = "*******_elite";
$db['elite']['password'] = "elite";
$db['elite']['database'] = "*******_elite";
$db['elite']['dbdriver'] = "mysql";
$db['elite']['dbprefix'] = "ig_elite_";
$db['elite']['pconnect'] = FALSE;
$db['elite']['db_debug'] = TRUE;
$db['elite']['cache_on'] = FALSE;
$db['elite']['cachedir'] = "";
$db['elite']['char_set'] = "utf8";
$db['elite']['dbcollat'] = "utf8_general_ci";

Knows someone what's happening? is the 2nd host with same problem.


MySQL Connection Problem - El Forum - 09-05-2009

[eluser]Mareshal[/eluser]
error fixed:

$db['elite']['db_debug'] = FALSE;

but now I have another problem:

Fatal error: Call to a member function num_rows() on a non-object in /home/*****/public_html/elite/dev/libraries/E_db.php on line 18

e_db is my library

Code:
function check($table, $where){
        $query = $this->ci->db->get_where($table, $where);
        return $query-> num_rows();
    }

this is the code

I tried affected_rows or return $this->ci->db->count_all_results(); but nothing

Fatal error: Call to a member function num_rows() on a non-object in /home/*****/public_html/elite/system/database/DB_active_rec.php on line 1080

in logs I see same error


MySQL Connection Problem - El Forum - 09-07-2009

[eluser]philpalmieri[/eluser]
I'm getting the same thing, but it only started happening on my new 10.6 install with MAMP Pro 1.8 (PHP 5.2.10)


MySQL Connection Problem - El Forum - 09-08-2009

[eluser]Phil Norton[/eluser]
[quote author="philpalmieri" date="1252396960"]I'm getting the same thing, but it only started happening on my new 10.6 install with MAMP Pro 1.8 (PHP 5.2.10)[/quote]

Yup, I'm getting the same issues. I had a site running locally that used a web database, and all worked perfectly 'til I upgraded MAMP Pro. Is this a MAMP issue, or Snow Leopard?


MySQL Connection Problem - El Forum - 09-08-2009

[eluser]wabu[/eluser]
Could it be related to the CI version (1.7.1 vs. trunk)?


MySQL Connection Problem - El Forum - 09-08-2009

[eluser]Phil Norton[/eluser]
Downloaded the latest version from trunk (Rev 1736) and the same thing happens...


MySQL Connection Problem - El Forum - 09-08-2009

[eluser]wabu[/eluser]
Is everybody getting the error only with num_rows()? If it's just general problems are you able to connect with vanilla PHP (such as: http://www.php.net/manual/en/mysql.examples-basic.php)?

I installed MySQL today and it seems to be working (returning a simple count with num_rows() as above), but that was from source and not as part of the MAMP package so maybe that's the problem.

I'm running Snow Leopard, MySQL 5.1, PHP 5.3.0 (SL default) and CI Rev 1736. If anybody wants me to try another non-MAMP test with my configuration let me know.


MySQL Connection Problem - El Forum - 09-09-2009

[eluser]philpalmieri[/eluser]
Hey, so the problem (for me anyway) was that the new MAMP/PRO my.cnf is missing the bind declaration.

Add "bind-address = 127.0.0.1" without the quotes, and reload mamp... all worked for me after.