Ubuntu/Drupal: PHP can not connect to other MsSQL Server - php

I copied one of our test servers and now I'm having a weird issue.
We have 2 MsSQL-servers, but I can only connect to one of them. I can not find any configuration issues that should cause this and other test server can connect to both fine. Any tips what could cause the issue and where to look?
The only clue is this in Drush logs:
2744375 11/Mar 12:46 php warning Warning: mssql_connect(): Unable to connect to server: MY.SQL.SERVER in eval() (line 4 of /srv/drupal/modules/php/php.module(80) : eval()'d code).

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

Warning: mysql_select_db(): Error while reading INIT_DB's OK packet. PID=8808

I keep on getting this error I dont know when it started. Sometimes my program runs without that error sometimes it has this error. Please help!!
I have uploaded file same as this one with error but when i look at the webpage it is running smoothly
I tried changing ports and restarting my wamp but it doesnt get any better
Warning: mysql_select_db(): Error while reading INIT_DB's OK packet. PID=8808
Warning: mysql_select_db(): MySQL server has gone away in
connection on line 4
Line 4 ----> mysql_select_db('dbname')
I think Now will be fined;
mysqli_connect("localhost","root","password","dbname");

CodeIgniter database error when opening the website

The website works fine for a while but in a few days returns this error :
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2002): Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /var/www/html/application/controllers/Login.php Line: 8
Function: database
File: /var/www/html/index.php Line: 289 Function: require_once
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/CodeIgniter.php
Line Number: 500
Help will be appreciated
Thanks
Nipun
Three things possible. Your database has been shut down (or it has died). You have not setup database to use a unix socket when both client and server are on the same machine. Or socket is not readable and writable by web user.
The warning is being thrown by mysqli driver. I would recommend that you use PDO driver to connect to the Database.It's simpler and a bit universal (You don't need to change Database settings once you change the DB)
you need confirm the database config file:application/config/database.php ensure the confirm item is correct
Please check your mysql server connectivity
If you run the app using your pc name i.e.
sahil-pc/recruitement or http://85.215.963.104:81/recruitement
you need to define it in index.php of root.
please check the permission of your db socket if you are using linux you need to make it in read and write mod.
note: ip details are fake don't try it

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.

Intermittent error connecting to my localhost MySQL instance from PHP: mysqli_connect(): HY000/2013

I have a LAMP website (PHP/MySQL), and I rely heavily on my MySQL database.
Recently, the following error started occurring intermittently:
[30-Oct-2011 16:11:49] PHP Warning: mysqli_connect() [<a href='function.mysqli-connect'>function.mysqli-connect</a>]: (HY000/2013): Lost connection to MySQL server at 'sending authentication information', system error: 32 in /home/path/to/my/code.php on line 1029
This is line 1029, the specific line that occasionally gives the above error:
$db = mysqli_connect($cfg['db_location'], $cfg['db_reader_username'], $cfg['db_reader_password']);
where $cfg['db_location'] is "localhost", and the username and password are correct.
It appears as though something is causing my PHP script to intermittently lose connection to the MySQL server, which is puzzling to me because all of my MySQL connections are made to localhost. That is, the PHP script and the MySQL server are both running on the same box, and I connect to MySQL via localhost.
Additionally, this is puzzling because my PHP script is able to successfully connect to the MySQL server for perhaps 90% of pages.
As best I can tell, my server has plenty of available RAM and CPU:
top - 16:38:23 up 173 days, 19:19, 2 users, load average: 0.57, 0.78, 0.84
Tasks: 142 total, 4 running, 137 sleeping, 0 stopped, 1 zombie
Cpu(s): 18.7%us, 27.5%sy, 0.7%ni, 52.6%id, 0.2%wa, 0.1%hi, 0.2%si, 0.0%st
Mem: 2976260k total, 1861368k used, 1114892k free, 532628k buffers
Swap: 2048248k total, 116k used, 2048132k free, 1035804k cached
And plenty of available disk space. When I run df -h, all of my filesystems are at most 25% in use.
So I don't know what would be causing the sporadic errors that I'm seeing in my PHP error logs.
Any ideas what might be causing my PHP script to intermittently lose connection to my MySQL server on localhost?
I upgraded to MySQL 5.1, and this is now what get when I run mysql -V:
mysql Ver 14.14 Distrib 5.1.56, for pc-linux-gnu (i686) using readline 5.1
The same errors are still happening, though:
[30-Oct-2011 20:26:18] PHP Warning: mysqli_connect() [<a href='function.mysqli-connect'>function.mysqli-connect</a>]: (HY000/2013): Lost connection to MySQL server at 'sending authentication information', system error: 32 in /home/path/to/my/code.php on line 1029
As before, the errors continue to be intermittent.
After I upgraded to MySQL 5.1, I've been looking carefully at my PHP errors logs. I've noticed a few other errors similar to the first one. For example, here's one such error:
[30-Oct-2011 22:42:29] PHP Warning: mysqli_connect() [<a href='function.mysqli-connect'>function.mysqli-connect</a>]: (HY000/2013): Lost connection to MySQL server at 'reading authorization packet', system error: 104 in /home/path/to/my/code.php on line 1029
And here's another error I've seen in my logs:
PHP Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/path/to/different/code.php on line 7
In all cases, the problem fundamentally seems to be a failure to connect to MySQL. Any ideas what might be causing this or how I could debug it?
Perhaps this bug report will help - It seems that a fix may be to set a higher timeout for the global connect_timeout. It was set to a higher value in later versions of MySQL 5.1 (10 seconds) as opposed to 5 seconds for earlier versions.
http://bugs.mysql.com/bug.php?id=28359

Categories