. .

PHP MySQL

» PHP 5 » PHP MySQL

, ( 12.2).

12.2. .

‹html›
‹head›
‹title› ‹/title›
‹/head›
‹body›
‹?php
//
if (!$link = mysql_connect("localhost", "root", ""))
{
  echo "‹br›He ‹br›";
  exit();
}
echo "‹br› ‹br›";
//
if (!mysql_create_db("test_db", $link) )
{
  echo "‹br›He ‹br›";
  exit();
}
echo "‹br› ‹br›";
//
mysql_close($link);
?›
‹/body›
‹/html›

mysql_create_db(). (test_db), - . mysql_create_db() TRUE, - FALSE.

mysql_drop_db(), , mysql_create_db(). , . SQL- ( 12.3).

12.3. .

‹html›
‹head›
‹title› ‹/title›
‹/head›
‹body›
‹?php
//
if (!$link = mysql_connect("localhost", "root", ""))
{
  echo "‹br›He ‹br›";
  exit();
}
echo "‹br› ‹br›";
//
$str_sql_query = "CREATE DATABASE test_db";
//
if (!mysql_query($str_sql_query, $link))
{
  echo "‹br›He ‹br›";
  exit();
}
echo "‹br› ‹br›";
// ,
mysql_close($link);
?›
‹/body›
‹/html›

, . mysql_connect(), SQL-. SQL, . CREATE DATABASE , . (test_db). , . SQL- , mysql_query(). , - . TRUE, , FALSE .

SQL- :
DROP DATABASE test_db

, , , DROP DATABASE , .