MySQL DB connection error

I’ve been mucking around with Flash Builder (beta 2) and trying to get some PHP services hooked up. It’s dead simple through FB assuming no hiccups. But I’ve been hiccupping for days now.

I’m running the latest WAMP install with only one modification mentioned below (fresh install) on WinXPSP2.

TO sum up, I have a very simple DB table set up, primary key + 4 other fields. I have a sample PHP service set up to talk communicate with MySQL and receive the table row data. However, whether I try to connect through FB, or just running a test.php which utilises the same PHP service, I get these errors from MySQL:

**Warning: mysqli_connect() [function.mysqli-connect]: MySQL server has gone away in C:\wamp\www\PHPService\services\EmployeeService.php on line 33

Warning: mysqli_connect() [function.mysqli-connect]: Error while reading greeting packet. PID=1024 in C:\wamp\www\PHPService\services\EmployeeService.php on line 33

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2006): MySQL server has gone away in C:\wamp\www\PHPService\services\EmployeeService.php on line 33

Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\PHPService\services\EmployeeService.php on line 27**

As suggested on an Adobe FB forum, I tried increasing my default ‘max_execution_time = 30 ;’ in php.ini upto 120, 240 and then 360 in that order. No cigar.

This url: http://www.codefinger.co.nz/_etc/mySQLError.zip contains;

  • MySQL Database table I’m using
  • EmployeeService.php as seen i the above error
  • test.php, in the same folder as EmployeeService.php

Any help appreciated, I’m no MySQL or PHP wiz, everything provided has been taken from online example materials from Adobe, all I’ve done is put in my own DB details and an altered version of ‘EmployeeService.php’ to reflect the data I’m trying to get from MySQL.

If you’re keen to help and I haven’t included some vital logs or whatnot, just holler and maybe let me know where I can find what you need to troubleshoot.

Cheers,
– danjah

[edit] I should note that in ‘EmployeeService.php’ you’ll see I commented out the username/pswd settings, just to test if that was a problem, I have tried it with the correct creds though (the commented ones). I also turned my firewall off temporarily while testing, shrug.

Answer

The problem is connecting to your MySQL server. You are able to connect via phpMyAdmin, correct? So MySQL itself appears to be connected correctly.

Looking at your code, this looks very very suspicious:

  var $server = "localhost"; 
  var $port = "80"; 

Port 3306 is the default MySQL port, but you may have configured yours to run on something else, I don’t know. But running MySQL on port 80 would be pretty dumb, since that’s the port for HTTP. I assume you have a webserver (Apache) running on that port, since you mentioned WAMP. Unless you changed Apache to run on a different port, which would be even weirder.

Attribution
Source : Link , Question Author : danjah , Answer Author : davr

Leave a Comment