NextIndexPrevious

Programs in PHP

17. Program to create a New Database using PHP and Mysql.
<?php

if(!mysql_connect('servername','username','password'))
{
	die('Connection failed!'.mysql_error());
}

$sql = "create database newdb";

if(mysql_query($sql))
{
	echo "Database created";
}
else
{
	echo mysql_error();
}

?>

-------------------------------------------------------------
Note: When we are using XAMPP or WAMP,
servername = localhost, username = root, password is empty.

Father of PHP

Rasmus Lerdorf

Rasmus Lerdorf

Born: November 22, 1968, Greenland