. .

    @Mail.ru -

PHP MySQL

» PHP 5 » PHP MySQL

, test_db, . , book, ( 12.4).

12.4. .

‹html›
‹head›
‹title› ‹/title›
‹/head›
‹?php
$sdb_name = "localhost";
$user_name = "root";
$user_password = "";
$db_name = "test_db";
//
if (!$link = mysql_connect($sdb_name, $user_name, $user_password))
{
  echo "‹br›He ‹br›";
  exit();
}
//
if (!mysql_select_db($db_name, . $link))
{
  echo "‹br›He ‹br›";
  exit();
}
//
$str_sql_query = "CREATE TABLE book (id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
name VARCHAR(50),
author VARCHAR(50),
num_pages INT(10))";
//
if (!mysql_query($str_sql_query, $link))
{
  echo "‹br›He ‹br›";
  exit();
}
echo "‹br› ‹br›";
//
mysql_close($link);
?›
‹/body›
‹/html›

, , , .. . . mysql_select_db(), . . TRUE , - FALSE.

SQL-. CREAT TABLE , . ( book), , id ( ), name (), author (), num_pages ( ).

, - mysql_query().

, :
DROP TABLE book