Hello, currently on one of my development servers I have SQL Server 2014 installed, the problem I HAD was that when I executed any of my PHP sites connected to various databases I was getting SQLSTATE[HY2000][2002] Connection was activily refused... I fixed that error by forwarding the port through the firewall, however I get a new error now SQLSTATE[HY000] [2006] MySQL server has gone away and I can't figure out how to fix it. From what I read online it seems as though this error is caused because my max packet isn't large enough and the request is timing out. I changed the max packets from 4MB to 60MB (very large I know but I figured if it worked I could lower it slowly finding a good value) but it is still giving me the same error. Basically I took this script from a web host I am paying for using their database which I will provide specs to below as well as their PHP version and this new local server's php version, and installed PHP using IIS 8 and SQL Server 2014. I then replicated the database in SQL Server 2014 as I couldn't directly import it due to the .sql file that PHPMyAdmin made being of different syntax it seemed then allowed. With the replicated database I checked what accounts had permissions and I then took the php code and edited the connection statements keeping it localhost but using port 1433 and using the correct username and password which happen to be local admin credentials to our domain. First thing I got was the error about the connection being refused and after fixing that I am now getting this new error with the server has gone away. To ATTEMPT to fix that issue I changed the max packet size in the advanced settings area of the SQL Management studios and then restarted the SQL server to update the changes and attempted to run the script again at which point it failed again. Any help would be great as when I get this server up and running I want to start learning languages from the .net stack and start a local ASP site.

Here is the mySQL server that the web host is using:

Server: Localhost via UNIX socket
Server type: MariaDB
Server version: 5.5.44-MariaDB-cll-lve - MariaDB Server
Protocol version: 10
User: petrzilk@localhost
Server charset: UTF-8 Unicode (utf8)
Engine: InnoDB

PHP Version from web server:

Local Server PHP Info:


Here is the code I am trying to run (part of it):


If there is anything I am leaving out please let me know! I will try to help as much as I can. This is my first SQL server install as well as IIS + php.

Recommended Answers

All 5 Replies

This is a bit confusing, you seem to be jumping from referring to MySql databases to SQL Server databases.
What db type are you trying to connect to, what is the exact error you are getting now and is it for all connections or when you are trying to a certain thing (like insert or date records)?

Basically the script was developed on a paid web hosting site and now I am trying to move it over to a local server that has SQL Server2014 installed along with IIS 8 + php. The error is: SQLSTATE[HY000] [2006] MySQL server has gone away which happens anytime I try to access the database. I fixed a previous error which was caused by the firewall blocking connections but now I am at this point where I believe I am connecting to the databsae but the queries are timing out.

Right, I should have seen the code you linked in your first post, my bad. You have this line:
$dbh = new PDO('mysql:host=localhost:1433;dbname=ItemAssetDB', '', '');
which is, obviously, using PDO to connect to a mysql instance - which isn't what you're trying to do.
First step is to switch that line to:
and see what happens.

@hericlesOkay I have it now to a point where the login is incorrect. hm... I can see it is typed 100% correct so there must be a problem using this account. Any ideas? I can attach an image of the secruity page if needed where it says this user has permissions.

I think all is good, I made a new user and login using Transact-SQL from a tutorial online and now it seems as though everything is working perfectly!
Thanks for your help! You're tip on mssql lead me right to the answer, though I do want to note mssql didn't quite work because of the PDO version I am using but changing to sqlSrv did and changing host to server. But you saying to change it totaly highlighted the answer. Thank you much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.