PHP kullanarak bir MySQL veritabanına nasıl bağlanabilirim?

// Connect To Database

// * mysql_connect takes the servername, user,
// * and password as arguments. mysql_select_db
// * takes the database name. Together, they
// * open a connection to your database.

mysql_connect($SERVER,$USER,$PASSWORD);

mysql_select_db($DATABASE);

// Execute Query
// * mysql_query takes as its argument the query
// * you are executing on the database. It should
// * be assigned to a variable — the variable is
// * used by other functions to retrieve the results.

$QUERY = mysql_query(“SELECT * from test”);

// How many rows in results?
// * mysql_num_rows takes the variable the query
// * Was assigned to (referred to hereafter as the
// * query identifier) and returns the number of rows
// * the query resulted in.

$RESULT = mysql_query($QUERY);
$NUMROWS = mysql_num_rows($QUERY);

// Display Results

if ($NUMROWS) { $I = 0; while ($I<$NUMROWS) {

// Get Results
// * mysql_result returns the value of a specific field
// * in a specific row. It takes three arguments: the
// * first is the query identifier, the second is the row
// * number, and the third is the field name. In this
// * example, a while loop is used to process all
// * rows.

$FIELD1 = mysql_result($RESULT,$I,”field1″);

$FIELD2 = mysql_result($RESULT,$I,”field2″);

$FIELD3 = mysql_result($RESULT,$I,”field3″);Eko

“field1 = $FIELD1, field2 = $FIELD2, field3 = $FIELD3 \n”;
$I++;

}}

?>