Welcome Guest, Not a member yet? Register   Sign In
Can't access to ovh database in my local setting ( database.php )
#1

[eluser]Kikito[/eluser]
Hello, my problem is I can't access to ovh database.

I make my admin panel in local with online database.

So here is my database.php

Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'mysql1-6.perso';
$db['default']['username'] = 'something';
$db['default']['password'] = 'something';
$db['default']['database'] = 'something';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

My error message is :
Quote:Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 232

Do you know what's problem ?
#2

[eluser]John_Betong_002[/eluser]
Try this:
 

Append this line to ./application/config/database.php
Code:
include 'database_DEBUG,php';
 

Copy and save the following file.
 
file: ./application/config/database_DEBUG.php
Code:
<?php

    // cosmetic    stuff
    define('xxx',    '<p>Line:    %s : %s    </p>');
    
    // show    parameters        
    echo '<pre>';
        print_r($db['default']);
    echo '</pre>';
    
    // try to    connect    to database    using    username and password
    $dbh = @ mysql_connect
                (
                    $db['default']['hostname'],
                    $db['default']['username'],
                    $db['default']['password']
                 );
    if(mysql_error())    
        echo sprintf(xxx,    __LINE__,    mysql_error());                
    
    
    // try to    select database
    $connected = @ mysql_select_db ($db['default']['database']);
    if (mysql_error())
        echo sprintf(xxx,    __LINE__,    mysql_error());                
    
    
    // display success/failure
    $msg    =    '';    // default
    if($connected)
    {
        $msg = 'Connected    OK';
    }//
    echo sprintf(xxx,    __LINE__,    $msg);            

    $query = mysql_query('SELECT * FROM stock_categories');
    
    // Check result
    // This shows the actual query sent to MySQL, and the error. Useful for debugging.
    if (!$result)
    {
      $message  = 'Invalid query: ' . mysql_error() . "\n";
      $message .= 'Whole query: ' . $query;
      die($message);
    }    
    echo 'Success';
    // return $query->result()    
    die();
&nbsp;
&nbsp;
#3

[eluser]adityamenon[/eluser]
Awesome idea! One keeps discovering new ways of manipulating CI in these forums every other minute! Smile
#4

[eluser]Kikito[/eluser]
Code:
Unknown MySQL server host 'mysql1-6.perso' (2)

I'll try to find the good adress

Great DEBUG module.
#5

[eluser]Kikito[/eluser]
I no found , nothing work Sad
#6

[eluser]John_Betong_002[/eluser]
[quote author="Kikito" date="1310313081"]I no found , nothing work Sad[/quote]

Try creating a new database on your host and if it is cPanel then it will give you a sample PHP script with your database settings.
&nbsp;
&nbsp;
#7

[eluser]Kikito[/eluser]
I ask ovh and the answer is simple :

OVH does not allow remote connections
#8

[eluser]John_Betong_002[/eluser]
If you can access your online OVH MySql database:

1. export your online OVH database data to your local hard-drive
2. open http://localhost/phpmyadmin/
3. create a new 'something' database and import the data

Use this new setting:

./application/config/database.php
Code:
if(! defined('LOCALHOST'))
  {
    define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);
  }

  $db['default']['hostname'] = LOCALHOST ? 'localhost' : 'mysql1-6.perso';
&nbsp;
You will now be able to run your application from http://localhost/
&nbsp;
&nbsp;
#9

[eluser]Kikito[/eluser]
Yes i made that but it's not in real time




Theme © iAndrew 2016 - Forum software by © MyBB