Name

mysql_create_db

Synopsis

boolean mysql_create_db (string database [, cresource connection])

Creates a new database with the name supplied as the database parameter. The function takes an optional connection resource handle as the second parameter. If no second parameter is passed, the most recently opened connection that is still open is assumed. To use the database after creating it, you must call mysql_select_db( ).

Returns true on success and false on failure.

Example

<?php
  $connection = mysql_connect("localhost", "fred", "shhh");
  
  if (mysql_create_db("temp", $connection))
     echo "Created database 'temp'";
  else
     echo "Create database 'temp' failed!";
?>

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.