Welcome Guest, Not a member yet? Register   Sign In
Can't Connect to Database On WebhostingUK Server
#1

[eluser]benners[/eluser]
I'm new to CI and I have a problem connecting to a local MYSQL DB on www.webhosting.uk.com.

I can connect to this MYSQL DB fine via a local installation of CI running in EasyPHP and also from a CI installation on Heart Internet. My CI installation on www.webhosting.uk.com gives an error connecting to this local database. I've tried localhost and the IP and I still get errors. I've done a manual connect on the www.webhosting.uk.com and this works.

Code:
// Make a MySQL Connection
mysql_connect("localhost", "dbusr", "pass) or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());

// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM table")
or die(mysql_error());


My guess is a PHP config problem on www.webhosting.uk.com affecting CI.

Quote:The CI error is:
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346

Does anyone know the problem or anyway I can find out more details on the error?

Thank you.
#2

[eluser]CroNiX[/eluser]
Show your database config that you are using with CI in /application/config/database.php. (you can change password or whatever for privacy)

Also show how and where you are loading the CI database object.

The above code you are posting has nothing to do with the error you are seeing, because your code is using pure php/mysql and not using the CI database object, but that is a CI database error.
#3

[eluser]benners[/eluser]
$autoload['libraries'] = array('database')

$db['webhostinguk']['hostname'] = 'SERVER_IP';
$db['webhostinguk']['username'] = 'UN';
$db['webhostinguk']['password'] = 'PW';
$db['webhostinguk']['database'] = 'DB';
$db['webhostinguk']['dbdriver'] = 'mysql';
$db['webhostinguk']['dbprefix'] = '';
$db['webhostinguk']['pconnect'] = TRUE;
$db['webhostinguk']['db_debug'] = TRUE;
$db['webhostinguk']['cache_on'] = FALSE;
$db['webhostinguk']['cachedir'] = '';
$db['webhostinguk']['char_set'] = 'utf8';
$db['webhostinguk']['dbcollat'] = 'utf8_general_ci';
$db['webhostinguk']['swap_pre'] = '';
$db['webhostinguk']['autoinit'] = TRUE;
$db['webhostinguk']['stricton'] = FALSE;
#4

[eluser]CroNiX[/eluser]
Try using the mysqli driver and setting pconnect to FALSE
#5

[eluser]benners[/eluser]
It works! Much appreciated! I've spent ages trying to sort that. It seems it just needed pconnect to FALSE and either driver works.
#6

[eluser]InsiteFX[/eluser]
pconnect is EVIL!




Theme © iAndrew 2016 - Forum software by © MyBB