Investigating mssql_connect problems in PHP - php

Today, I restarted my CentOS server and after that my PHP application started to fail in accessing our MsSQL server.
[Sun Mar 13 23:44:31 2011] [error] [client 88.154.*.*]
PHP Warning: mssql_connect()
[<a href='function.mssql-connect'>function.mssql-connect</a>]: Unable to connect to server: 85.*.*.109
MsSQL server uses port 1433.
I'm able to get a connection when I try telnet ip 1433 to MsSQL server.
Username and password combination is correct, I'm able to login from another machine.
Nothing has been changed in security settings of MsSQL server.
How can I see what's wrong?

did you double check and make sure that ALL of sql server's services have started?

Related

MySQL server has gone away - Packets out of order. Expected 0 received 1. Packet size=72

I tried to use php to connect to a MySQL sever running on another computer on the same network.
Server IP: 192.168.0.111
My IP: 192.168.0.109
I am currently using XAMPP which I just upgraded to version 8.0.0. After the upgrade, I got a few errors on my screen:
Warning: Packets out of order. Expected 0 received 1. Packet size=72 in C:\xampp\htdocs\submit.php on line 95
Warning: mysqli::__construct(): Error while reading greeting packet. PID=28684 in C:\xampp\htdocs\submit.php on line 95
Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in C:\xampp\htdocs\submit.php on line 95
Connection failed: MySQL server has gone away
MySQL server is running on the default port 3306 and here are the latest logs:
2020-12-27 16:11:21 29 [Warning] IP address '192.168.0.109' has been resolved to the host name '192.168.0.109', which resembles IPv4-address itself.
2020-12-27 16:11:21 29 [Warning] Aborted connection 29 to db: 'unconnected' user: 'unauthenticated' host: '192.168.0.109' (This connection closed normally without authentication)
The server is not using any password at the moment.
What can I do to fix this issue?
Thanks.
[update] I see no errors when I use server name as 'localhost' when the php file is on the MySQL server.

PHP: ssh2_connect: cant connect to localhost or machine remotely

For the sake of my explanation, keep the following im mind.
Machine 1 Internal = 127.0.0.1
Machine 1 External = 192.0.0.1
Machine 2 Internal = 127.0.0.2
Machime 2 External = 192.0.0.2
Client External = 10.0.0.1
So, I will try to connect to the internal IP of Machine #1, while on Machine #1:
$server = "127.0.0.1";
$conn = ssh2_connect($server, 22);
Results in [/var/log/httpd/error_log]:
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 127.0.0.1 on port 22 in /var/www/html/file.php on line 8
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 127.0.0.1 in /var/www/html/file.php on line 8
Changing the IP from internal to external yielded the same error.
Now, I will try to connect to the external IP of machine #1 while the PHP file is ran off of Machine #2's webserver:
$server = "192.0.0.1"
$conn = ssh2_connect($server);
Results in [/var/log/httpd/error_log]:
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 192.0.0.1 on port 22 in /var/www/html/file.php on line 8
[:error] [client 10.0.0.1:0000] PHP Warning: ssh2_connect(): Unable to connect to 192.0.0.1 in /var/www/html/file.php on line 8
All of this is the case, but oddly enough, if I run the exact code through the php -a interpreter, and proceed to authenticate and run a command, all works flawlessly.
What is the issue??
I was able to resolve this by using setenforce 0.
Honestly the most puzzling issue I've had while programming. Thanks for the help!

Bluemix PHP app fails on LDAP connection

This is a follow up ticket to one which was closed without answer:
https://stackoverflow.com/questions/34515574/ibm-bluemix-authentication-using-tivoli-ldap
I have migrated a PHP app which requires LDAP authentication to Bluemix and I am getting the following error:
2016-01-08T10:28:53.87+0000 [App/0] OUT 10:28:53 httpd | [Fri Jan 08 10:28:53.869250 2016] [proxy_fcgi:error] [pid 44:tid 139703240013568] [client 169.53.20.45:7120] AH01071: Got error 'PHP message: PHP Fatal error: Call to undefined function ldap_connect() in /home/vcap/app/htdocs/utils/LoginLDAP.Class.php on line 21\n', referer: http://sbrooms.w3ibm.mybluemix.net/index.php
Please note that this is not the public Bluemix, but the internal IBM one (w3ibm.mybluemix.net), hence the connection to the LDAP server should be available.
Do I have to explicitly request the connection to the LDAP server, or something else is going wrong?
Thanks,
Pimmy
Looks like the LDAP-Extension for PHP is not installed on the WebServer. The PHP message: PHP Fatal error: Call to undefined function ldap_connect() suggests that.
You can check that by adding a page to your webserver with the following content:
<?php
phpinfo();
Call that website in a webbroser and check whether there is any trace of the LDAP-extension. If not, you will need to get that extension. As there are many different ways to install it (from recompiling PHP to a call to your systems package-manager) I need more information on how your system - and especially PHP - has been installed.
Hope that helps!

Can not start phpmyadmin after updating mysql and php

I updated PHPMyAdmin, then saw some errors about different versions of MySQL libraries and server. So I uninstalled and reinstalled MySQL using YUM.
Now MySQL works and I can see the MySQL database server listed in webmin modules and it has the users and databases in there, but when I go to PHPMyAdmin an error occurs.
var/logs/httpd/error_log shows:
[Tue Oct 13 09:29:33 2015] [error] [client 193.109.196.106] PHP Fatal error: Class 'SqlParser\\Lexer' not found in /usr/share/phpMyAdmin/libraries/Util.class.php on line 634, referer: http://198.154.62.131/phpMyAdmin/
I tried searching for this error in Google but I found nothing.
This error is caused by mysql server version being way too old for the latest phpmyadmin.
I managed to update mysql using this method and now the phpmyadmin works again:
http://kwatog.com/blog/how-to-upgrade-mysql-5-0-to-5-5-in-centos/
But still the error is shown on phpmyadmin dashboard:
"Your PHP MySQL library version 5.0.67 differs from your MySQL server version 5.5.28. This may cause unpredictable behavior. "

Accidentally turn on SSL / HTTPS for phpmyadmin

I'm running Ubuntu 14.04.2 LTS, Apache 2.4.7, mysql 14.14, phpinfo.php
I was trying to reconfigure phpMyAdmin and I'm no longer sure what I actually did, because now all attempts to access the page result in a redirect to https, which doesn't work because my Apache server isn't configured to run SSL. I go to http://MYDOMAIN/phpmyadmin and it turns it into https://MYDOMAIN/phpmyadmin/?collation_connection=utf8_general_ci&SID which just has an SSL connection error.
I've tried uninstalling and reinstalling phpMyAdmin several times with no success.
If I go to http://MYDOMAIN/phpmyadmin/setup I get a blank screen but this line shows up in my weblogs:
[Tue Mar 24 05:09:10.518308 2015] [:error] [pid 8888] [client 50.161.45.55:49637] PHP Fatal error: Call to undefined function PMA_generate_common_url() in /usr/share/phpmyadmin/libraries/common.inc.php on line 352
I've tried creating and uncreating /usr/share/phpmyadmin/config/config.inc.php but it seems to have no effect.
Any ideas what I might have done and how I can revert back? mysql is still running fine and I'd rather not have to reinstall that.
Find phpmydmin's config.inc.php and change the line as follows:
$cfg['ForceSSL'] = false;

Categories