Copy link to clipboard
Copied
I am getting the following error the first time I open a php page that connects to the MySQL database.
Warning: mysql_pconnect() [function.mysql-pconnect]: MySQL server has gone away in C:\xampp\htdocs\check_php\check_mag.php on line 9
The 'check-mag.php' file in the Connections folder is written as follows and the data used in each of the 4 variables is correct
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_check_mag = "localhost";
$database_check_mag = "php_test";
$username_check_mag = "phptestuser";
$password_check_mag = "patricia68b";
$check_mag = mysql_pconnect($hostname_check_mag, $username_check_mag, $password_check_mag) or trigger_error(mysql_error(),E_USER_ERROR);
?>
This occurs on my 'local testing machine' (home network) and it only happens during the first load of the page after the machine has sat idle for a while; however, the page does display the data called for! If I 'refresh' the page or reopen it from a new iteration of IE8 on that machine it works fine.
Any thoughts?
BTW: What is the purpose of the '#' sign at the beginning of lines 2,3,4 in this file?
Thanks,
Tom
Copy link to clipboard
Copied
Tom,
What is the purpose of the '#' sign at the beginning of lines 2,3,4 in this file?
The lines starting with '#' are comments that store data for Dreamweaver, so do not edit them.
Sorry, I don't know why the server doesn't connect the first time, or a way to hack around it.
Randy
Copy link to clipboard
Copied
Randy,
Thanks for info. Figured it was such but I couldn't find a reference to the # sign anywhere (can't say I looked everywhere though). And having quite a problem connecting to the database 'on line' vs localhost, I had to consider the possibility one of (comment) lines was doing it. Finally determined that the connection problem was a hosting service requirement that wasn't 'spelled out' by them anywhere (they finally responded and cleared it up for me). If you look at the forum topic 'WEB Host Check', you will see the exchange. Of all things quite unexpected, I have to put my 'cPanel' login name before the DB name and username neither of which can have non-alphanumeric characters in them. Also, although the cPanel username input is tagged max 7 characters, it only allowed a max of 6 chars!
Again, thanks.
Tom
Find more inspiration, events, and resources on the new Adobe Community
Explore Now