Page 1 of 1

MySQL connectivity problem

Posted: Sat Apr 19, 2003 11:58 am
by desmondlk
Dear all,

I am developing a program by using PHP with MySQL database.

I encountered the connectivity problem.

When I click on a link or button to display list of records, sometimes MySQL suddenly shut down. I need to restart the service again.

May I know the problem regarding to this? Is it my coding error?

The following is the connection code that I used to connect MySQL DB.

Code: Select all

<?php
$link = mysql_connect("localhost") or die("Could not connect to database.\nPlease try again later. ");

mysql_select_db("Test");
?>
Please help. Thanks in advance.

Posted: Sat Apr 19, 2003 1:33 pm
by AlphaWolf
Does it crash all the time, or just some of the time?

Using mysql_connect() are you supplying a userid and password? If not, it assumes defaults.

mysql_connect() establishes a connection to a MySQL server. The following defaults are assumed for missing optional parameters: server = 'localhost:3306', username = name of the user that owns the server process and password = empty password.

Maybe this is the issue?

Posted: Sat Apr 19, 2003 1:36 pm
by AlphaWolf
Here is a good example of a connection string:

<?php
$connection = mysql_connect($your_host, $your_user, $your_pass);
$db = mysql_select_db($your_database, $connection);
?>