CodeIgniter Forums
DB Error after hosting deploy - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: DB Error after hosting deploy (/showthread.php?tid=53370)



DB Error after hosting deploy - El Forum - 07-21-2012

[eluser]snakeblu[/eluser]
Hi everybody,
I have just deployed a web application on my pc(local). This application works great.
After I have brought it on my site (keliweb hosting) I have this error:
Code:
Fatal error: Call to a member function num_rows() on a non-object in

Hosting respects alle Codeigniter system requirements (php and mysql).

Do you know how to solve it.

Thaks

Regards
Mauro


DB Error after hosting deploy - El Forum - 07-21-2012

[eluser]InsiteFX[/eluser]
Did you change your database.php to the new hosting values?



DB Error after hosting deploy - El Forum - 07-21-2012

[eluser]snakeblu[/eluser]
This is database configuration on host.
root, root and testdb are settings in my local environment.

I tried with localhost, 127.0.0.1 and with ip of my site.
I had some connection error solved by change db_debug from TRUE to FALSE.

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

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'my_host_user';     -->root
$db['default']['password'] = 'my_host_pass';     -->root
$db['default']['database'] = 'dbname';           -->testdb
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$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;

Sorry for my bad english.
Bye


DB Error after hosting deploy - El Forum - 07-21-2012

[eluser]InsiteFX[/eluser]
Ask your hosting provider they will tell you what it should be set to.

Look at their help center it is usally there.



DB Error after hosting deploy - El Forum - 07-21-2012

[eluser]J. Pavel Espinal[/eluser]
Hello Mauro,

Maybe double checking some details might give you some clue to solve the problem:

1. Did you configure any environment for development?
If so, get sure you create a directory with the current environment according to what your 'index.php' file indicates (development, testing, production).

Note: If CodeIgniter can not connect or can not select the database indicated in your config file, it will let you know it with a message like:
Code:
Unable to connect to your database server using the provided settings.
or
Code:
Unable to select the specified database: testDB

So this does not seems to be your case. Let's move forward.

2. Are you sure you loaded the database driver class (or added the file that was supposed to load it for you -autoload.php- to your environment dir)?

If you forgot to load the database class and try to use it, you will surely get the error mentioned in your comment.


Regards,





DB Error after hosting deploy - El Forum - 07-23-2012

[eluser]snakeblu[/eluser]
Since the code works on my pc with xampp, I think that there is a problem on db settings.
Now the model has only three rows of code:
Code:
$this->load->database();
$query = $this->db->query();
$query->num_rows();

I get the error when the function num_rows() is called, probably because the query returns nothing(the query is "select * from table_name" and works on phpmyadmin).

I used only one environment:
I developed the application on my pc and then I copied everything on the host server (of course I modified configuration files).

On the same db there is an opencart application. Maybe should I create a new user (ad hoc for the new application)?

Thanks
Bye


DB Error after hosting deploy - El Forum - 07-23-2012

[eluser]snakeblu[/eluser]
Solved...

From
Code:
$db['default']['dbdriver'] = 'mysql';
to
Code:
$db['default']['dbdriver'] = 'mysqli';

and now the app works

Bye
Mauro