Welcome Guest, Not a member yet? Register   Sign In
load->database() issue - sits at "waiting for localhost"
#1

[eluser]DevTyme[/eluser]
Hi there --

I've set up my database configuration files to how exactly MySQL settings are set.
I've placed this command ($this->load->database()) in my Controller before the load view.

Anyways, whenever load database is reached the browser just sits there with the loading icon on the tab and the progress text saying "Waiting for localhost...", showing that it is sitting on/awaiting a connection, but it never does anything.

Obviously when i comment this section out, the static page loads fine. When it's uncommented, the page never loads, just sits there attempting to load.

The page itself has no active queries, just static html, so there's no other possible issues other than the database loading.

I have XAMPP up to date running both Apache and MySQL. Also note that I can access phpMyAdmin fine, that works and loads at a fast speed, so MySQL is active.

Important pieces of database.php:
Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost:8080";
$db['default']['username'] = "root";
$db['default']['password'] = "root";
$db['default']['database'] = "test";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE; //tried both T/F
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

My Controller:
Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();
        $this->load->database();        
    }
    
    function index()
    {
        //$this->load->database(); //open connection
        $this->load->view('welcome_message');
        
    }
}

Database info:
Code:
/*
Server: localhost via TCP/IP
User: root@localhost
charset: UTF-8
MySQL client version: 5.1.37
Database name: test

*/
#2

[eluser]Cro_Crx[/eluser]
[quote author="DevTyme" date="1261467994"]

Code:
$db['default']['hostname'] = "localhost:8080";
$
[/quote]

Try removing the port from the hostname and put it in the port variable.

Code:
$db['default']['hostname'] = "localhost";
$db['default']['port'] = 8080;

Also make sure that your mysql connection is actually on 8080. You can do this by typing "telnet localhost 8080" into the terminal/command prompt. (For Windows Vista/7 you need to install the telnet client first, google it if you need).
#3

[eluser]DevTyme[/eluser]
[quote author="Cro_Crx" date="1261473830"][quote author="DevTyme" date="1261467994"]

Code:
$db['default']['hostname'] = "localhost:8080";
$
[/quote]

Try removing the port from the hostname and put it in the port variable.

Code:
$db['default']['hostname'] = "localhost";
$db['default']['port'] = 8080;

Also make sure that your mysql connection is actually on 8080. You can do this by typing "telnet localhost 8080" into the terminal/command prompt. (For Windows Vista/7 you need to install the telnet client first, google it if you need).[/quote]


Hey -- I tried setting a port variable but it did not make a difference. I am, however, thinking they may not be sharing a port. Telnet command line doesnt do anything, just sits there with a blinking space. Is there a configuration file where I can check what port it is running on? How can i change the default port for MySQL?

Thanks in advance
#4

[eluser]Cro_Crx[/eluser]
The default port for MySQL is 3306 so you could try that. If phpMyAdmin is working fine then it's setup to use the correct port so you could try opening the config.inc.php file within the phpMyAdmin folder.


Maybe try removing the port config item and just leave hostname set to localhost to see if that works ?
#5

[eluser]DevTyme[/eluser]
I've tried just localhost, no luck.

I'll also change apache's port to the MySQL port. Is there a way to change the MySQL port? I didnt see it in the MySQL config file
#6

[eluser]DevTyme[/eluser]
[quote author="Cro_Crx" date="1261560251"]The default port for MySQL is 3306 so you could try that. If phpMyAdmin is working fine then it's setup to use the correct port so you could try opening the config.inc.php file within the phpMyAdmin folder.


Maybe try removing the port config item and just leave hostname set to localhost to see if that works ?[/quote]

Are you sure you specific the port within config.inc.php? There's no attribute for it..

Or should I make my own such as:
Code:
$cfg['Servers'][$i]['port'] = portno.

This is the existing file, with no port definition:
Code:
<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

/*
* Servers configuration
*/
$i = 0;

/*
* First server
*/
$i++;

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type']            = 'config';
$cfg['Servers'][$i]['user']                 = 'root';
$cfg['Servers'][$i]['password']             = 'root';
$cfg['Servers'][$i]['AllowNoPassword']      = true;

/* Server parameters */
$cfg['Servers'][$i]['host']             = 'localhost';
$cfg['Servers'][$i]['connect_type']     = 'tcp';
$cfg['Servers'][$i]['compress']         = false;

/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb']            = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable']    = 'pma_bookmark';
$cfg['Servers'][$i]['relation']         = 'pma_relation';
$cfg['Servers'][$i]['table_info']       = 'pma_table_info';
$cfg['Servers'][$i]['table_coords']     = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages']        = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info']      = 'pma_column_info';
$cfg['Servers'][$i]['history']          = 'pma_history';
$cfg['Servers'][$i]['designer_coords']  = 'pma_designer_coords';

/*
* End of servers configuration
*/

/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir']   = '';
$cfg['SaveDir']     = '';

$cfg['AllowAnywhereRecoding']       = true;
$cfg['DefaultCharset']              = 'utf-8';
$cfg['DefaultLang']                 = 'en-utf-8';
$cfg['DefaultConnectionCollation']  = 'utf8_general_ci';

$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman/5.1/en';
$cfg['MySQLManualType'] = 'searchable';

?>
#7

[eluser]DevTyme[/eluser]
UPDATE:::

I just shared a port with apache and mysql and mysql wouldn't be able to start up (used mysql's default port, 3306, as apache's port).

Looks like they won't share one, are they really supposed to?
#8

[eluser]John_Betong[/eluser]
[quote author="DevTyme" date="1261615379"]UPDATE:::

I just shared a port with apache and mysql and mysql wouldn't be able to start up (used mysql's default port, 3306, as apache's port).

Looks like they won't share one, are they really supposed to?[/quote]
 
I have this code at the end of every ./config/database.php. The code just tries to connect to the database using the CodeIgniter $config settings passed to the standard PHP/MySQL login script.

Code:
if (! FALSE) // Supplied by Cpanel script to connect to my database
{
  echo '<pre>';
      print_r($db['default']);
  echo '</pre>';
  
  echo '<br />Trying to connect to database: ' .$db['default']['database'];
  $dbh=mysql_connect
      (
          $db['default']['hostname'],
          $db['default']['username'],
          $db['default']['password']
         )
        or
        die
        (
          'Cannot connect to the database because: ' . mysql_error()
         );

  mysql_select_db ($db['default']['database']);

  echo '<br />Success - connected OK:';

  die(__LINE__);

}//endif
&nbsp;
Once you have managed to secure a connection then make the test FALSE again and move on to your next problem Smile
&nbsp;
&nbsp;
edit: spelling - I hope Father Christmas brings me a new keyboard that can spell correctly.
&nbsp;
&nbsp;
#9

[eluser]flaky[/eluser]
Only one application can have one specific port.
Example
If apache is using port 80, no other application can use that port, so ports can not be shared between applications.

Default port for apache is 80
Default port for mysql is 3306
#10

[eluser]malcom1234[/eluser]
is your issue resolved? i am running in to same problem but in my case i get http 500 error with just that 1 line of laod database?
thx
malcom




Theme © iAndrew 2016 - Forum software by © MyBB