Welcome Guest, Not a member yet? Register   Sign In
Error mysql_pconnect() when site goes live
#1

[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.
#2

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

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

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

[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?
#4

[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.
#5

[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!
#6

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

[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
#8

[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




Theme © iAndrew 2016 - Forum software by © MyBB