Book: PHP & MySQL Second Edition the missing manual
Chapter 10: Connecting Users and Images
Problem: I've been following the book's finished example code for this section and can't get it to work. I get these two errors:
Warning: mysql_query(): MySQL server has gone away in C:\wamp\www\PHPMySQL2e_MissingCD\PHPmm2e_ch10_examples\04-Connecting Users and Images\create_user.php on line 96
Warning: mysql_query(): Error reading result set's header in C:\wamp\www\PHPMySQL2e_MissingCD\PHPmm2e_ch10_examples\04-Connecting Users and Images\create_user.php on line 96
I read on Stack Overflow that it might be a connection timeout with the database. As you can probably tell, I'm running the server locally. I am hoping for a customized solution to this problem from the book's contributors—otherwise I will read more on Stack Overflow.
Apache Version: 2.4.4
PHP Version: 5.4.12
MySQL Version: 5.6.12
Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I have forwarded your question on to our Book Tech staff, so they can help you find a solution. If you ever have any questions or issues with the content of a title, you can also contact them directly at firstname.lastname@example.org or call them at:
1-707-827-7019 (outside the USA)
7:30 am to 5:00 PST
Customer Service Representative
Yes, that does sound like a timeout error and MySQL is closing the connection before you can run the query. Have you tried increasing the mysql.connect_timeout and default_socket_timeout in the php.ini file?
This page lists the possible reasons for getting that error and some work arounds -
I hope that helps,
O'Reilly Book Support