CodeIgniter Forums
Error mysql_pconnect() when site goes live - 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: Error mysql_pconnect() when site goes live (/showthread.php?tid=40214)



Error mysql_pconnect() when site goes live - El Forum - 04-01-2011

[eluser]keld[/eluser]
Hello,

I've been working on this site for a while locally using WAMP 2.0 and my database is hosted live with my current web host. Everything works fine when today to test some functionalities I decided to create a subdomain for testing and deploy my site there but I get a cannot connect to database error. I looked at the log files and here is the error:

ERROR - 2011-04-01 14:12:34 --&gt; Severity: Warning --&gt; mysql_pconnect() [<a href='function.mysql-pconnect'>function.mysql-pconnect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) /home/content/23/7680523/html/dev/system/database/drivers/mysql/mysql_driver.php 88
ERROR - 2011-04-01 14:12:34 --&gt; Unable to connect to the database

I don't understand because I tested the connection by uploading a simple
Code:
mysql_connect($hostname,$username, $password) OR DIE();
with a query and it returned the results fine.
Is there something to do in codeginiter when pushing live?

Thanks a lot in advance I'm really stuck.


Error mysql_pconnect() when site goes live - El Forum - 04-02-2011

[eluser]Bart v B[/eluser]
In the application/config/config.php
change:

Code:
$db['default']['pconnect'] = TRUE;

to
Code:
$db['default']['pconnect'] = FALSE;



Error mysql_pconnect() when site goes live - El Forum - 04-02-2011

[eluser]keld[/eluser]
Thanks Bart it worked! not sure what the pconnect is all about, maybe my webhost doesn't have this module loaded.
Anyway, my homepage shows up fine but if I click a link to go to another page I get a 500 Internal Server error, any idea why?
I used to have this error before when I didn't use ASCII mode to upload the htaccess file at the root of the folder, but I don't get why the home page would work and the others?


Error mysql_pconnect() when site goes live - El Forum - 04-02-2011

[eluser]Bart v B[/eluser]
yes,

i guess that you need to changce the base_url also in your config.
pc_connect() is a bad practice for shared hosting. Wink
share some code aboute the .htaccess, and your config file so we can look at it.


Error mysql_pconnect() when site goes live - El Forum - 04-02-2011

[eluser]keld[/eluser]
Hey thanks, this is my htaccess:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

This is the root in my config file
Code:
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = "$root";

And I have another base url in my header in template.php so I can use base_url in the js iles:
Code:
[removed]
  // < ![CDATA[
  base_url = '&lt;?= base_url();?&gt;';
  //]] >
[removed]
&lt;base href="&lt;?php echo base_url() ?&gt;"&gt;

Thanks!


Error mysql_pconnect() when site goes live - El Forum - 04-02-2011

[eluser]keld[/eluser]
BTW my host is godaddy.com, not the greatest but...


Error mysql_pconnect() when site goes live - El Forum - 04-03-2011

[eluser]Bart v B[/eluser]
Just try it the basic way, so that it almost alway's works.

Code:
$config['base_url'] = 'http://www.youre_url.com/';

mind the slash on the end.. Wink


Error mysql_pconnect() when site goes live - El Forum - 04-03-2011

[eluser]InsiteFX[/eluser]
p_connect has a lot of timming problems, there are ways to fix it but its not easy!

MySQL timmings are in the my.cnf file you can change timmings in it for localhost but you cannot change these on a live server!

InsiteFX