MySQL connectivity problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
desmondlk
Forum Commoner
Posts: 27
Joined: Tue Sep 24, 2002 10:27 pm
Location: Malaysia

MySQL connectivity problem

Post 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.
User avatar
AlphaWolf
Forum Newbie
Posts: 12
Joined: Sun Mar 23, 2003 8:49 pm

Post 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?
User avatar
AlphaWolf
Forum Newbie
Posts: 12
Joined: Sun Mar 23, 2003 8:49 pm

Post 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);
?>
Post Reply