CodeIgniter error when connecting to the database - php

I am trying to uplaod my web to a host, I've had some problems I managed to solve but no this one. It's related to the database, and it only happens sometimes.
In some cases I have to query the database or even for the user registration it works fine, but in other cases I got the error:
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
I debugged the error (thanks #Valeh Hajiyev: CodeIgniter: Unable to connect to your database server using the provided settings Error Message) and in every case the connection seemed to be fine.
I hope someone who has had this problem before could help me.
EDIT: Oh snap! I just found out that refreshing the page a couple of times makes it work. What??

Related

CodeIgniter Database Error but only one section of app

I have an existing web app but for no apparent reason one section of the app is now displaying the following error:
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 338
The rest of the app works fine and can connect using the same database credentials at application/config/database.php
Any help to point me in the right direction in terms of debugging the issue would be welcome.
This is for an existing Linux server, running MySQL 5, PHP 7 and Apache 2.
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 338

Lost connection to MySQL server during query - codeigniter

I just made a script in codeigniter which fetches emails and displays them with php imap.
It fetches 500 mails at once no problem.
If i try to fetch about 2000 mails at once, it throws an error.
A Database Error Occurred
Error Number: 2013
Lost connection to MySQL server during query
SELECT GET_LOCK('77dfd862ae2b7bedaec521bc4c3651952b56e6c9', 300) AS
ci_session_lock
Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 358
This project is live on hostgator. I am not sure if it has mysql workbench or not.
I have no idea where it comes from and why.
I have done nothing with mysql in codeigniter before.
I do not know which file to edit and where to start. Please help.

PHP Myadmin call to undefined function PMA_SQP_parse()

When working on my webpage, I reloaded twice to check the results after editing... and got this error when trying to acces my localhost database page:
Fatal error: Call to undefined function PMA_SQP_parse() in C:\xampp\phpMyAdmin\libraries\Util.class.php on line 1126
When I google for this issue, I only find 6 results, and I don't think any of the 6 would resolve my issue.
Has anyone had this issue before? I've looked on the PHPMyAdmin page, for support.. but the only result is them saying I have to ask my issue here...
Try clearing session storage for your phpmyadmin domain
Well, for anyone who is interested in a fix... for me rebooting my PC worked.

PHP mailer returning Fatal Error

I have been working on my first PHP contact form.
I have also been running into some problems. I have gotten the files to all talk to each other, and it has gotten to the point where it looks like it is going to work. But, after you input the information in the form, press send, it comes back with this error:
Deprecated: Function eregi() is deprecated in /home/content/12/11666412/html/phpMailer/class.phpmailer.php on line 594
Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.gmail.com:587 (Connection refused) in /home/content/12/11666412/html/phpMailer/class.smtp.php on line 122
Thank you!
So, I assume 2 things:
1: I should try using a different port # for connecting to google (587 has worked for me in the past on a different server, is this something that sometimes changes?). What port number should I be using?
2: Something is wrong in the PHP mailer files (that I downloaded from the PHPmailer site). Should I try redownloading them? I doubt anything is wrong with the PHPmailer, seems to be a very reputable tool that people use, the code is too advanced for me to analyze.
Any help would be appreciated.

More than max_user_connections in CodeIgniter app?

I'm getting what looks like rather serious database errors in my CodeIgniter application. In the log file it says:
User anders already has more than 'max_user_connections' active connections
And there are several hundred of those lines... I've read a bit by Googling, and some suggested that it was because you didn't close the connection after it was used, but others said that this was nonsense, and that the connection was automatically closed (which is what I read in the docs too).
Also, later in the log file, I have these error messages:
ERROR - 2011-10-12 10:50:19 --> Severity: Warning --> file_get_contents(http://localhost/expertinfo/error/error_general) [function.file-get-contents]: failed to open stream: HTTP request failed! /Applications/MAMP/htdocs/expertinfo/application/errors/error_general.php 4
This seems to have something to do with the fact that I'm using a custom error page by using
echo file_get_contents($config['base_url'] . 'error/error_db');
to redirect to a custom page.
Finally, I'm also getting:
ERROR - 2011-10-12 10:52:19 --> Severity: Warning --> mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'mydb24.surftown.se' (4) /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php 88
In these last two, I don't understand what the local path is doing there (The path to my CodeIgniter app on my computer). I mean this is a part of the system folder and the one on the remote server should be used, right? I have the database set up as the remote database, and I don't have any local paths as far as I know....
So why does this happen, and what can I do about it?
Please help, this seems rather urgent. I'm a bit of a newbie to both php and CodeIgniter too, so a clear and simple answer would be greatly appreciated!
Local path as I see shows you file where your error happened, because your driver /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php possible on it's 88 line contain connect() function and it raise an exception
The problem is with your mydb24.surftown.se remote server, you should check your access credentials, etc. to find what exactly happened
Just an FYI, mysql_pconnect is usually a bad practice on shared hosting (you can see why here:http://stackoverflow.com/questions/1830830/advantages-disadvantages-of-pconnect-option-in-codeigniter)
You might just disable pconnect on application/config/database.php and see the error going away as your connections will be realluy lower.
For the quote: "mysql_pconnect is usually a bad practice on shared hosting".
I changed to use mysql_connect. It made no difference.

Categories