Search the Community
Showing results for tags 'database connect'.
Found 1 result
I am wondering if someone can help me with an intermittent database connection problem that I have started to experience. My environment is: . Windows 7 Home Premium 64 bit . Internet Explorer 10 . Firefox 22.0 . Dreamweaver MX2004 as the text editor . Xampplite 1.7.3 which comprises: .. Apache 2.2.14 .. PHP 5.3.1 .. MySQL 5.1.41 The problem occurs intermittently in both IE10 and Firefox, so appears not to be related to the browser. The message that I get is (and I stress that I don't always get it): Warning - mysql_connect() [function MySQL-connect]: Unknown MySQL server host 'localhost' (11001) with a reference to the PHP line of code. This is immediately followed by Fatal error Unknown MySQL server host 'localhost' (11001) with a reference to the same PHP line of code. My connection code is: $dbc = mysql_connect($local_hostname_xx, $local_username_xx, $local_password_xx) or trigger_error(mysql_error(),E_USER_ERROR); I am using the PHP mysql functionality as the production system does not support the mysqli functionality. If I have a look at the database with HeidiSQL (which provides MySQL admin-like functionality) the database and its data are all there. Can you also provide some specific guidance re the following: 1) I have a lot of PHP scripts that enable an administrator to update many aspects of the database tables. Most use Larry's PHP redux technique. In each script I require_once the php connection code followed immediately by the mysql_select_db statement. Should I be using 'require' rather than 'require_once'? 2) The database connection code does not use a persistent mysql_connect - should I be using a persistent connection i.e., mysql_pconnect function instead? 3) I do not close the database connection in the PHP scripts - should I? I have been using similar code for years without a problem. The problem seems to have started when I was experimenting with 'require' and 'require_once' to include the database connection code. I was also experimenting with mysql_connect versus mysql_pconnect in the connection code itself. Any advice will be most appreciated and thank you in anticipation. Best regards, Necuima.