www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons Creating MySQL Database Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Actual data in a database is stored in tables and a database can hold one or multiple tables. Simply put, a database is a named collection of related tables. In this lesson we will see how we can create MySQL databases.

How to Create a MySQL Database?
We us the CREATE DATABASE statement to create a database in MySQL. Its syntax follows:

CREATE DATABASE database_name

How to Create a MySQL Database in PHP?
PHP provides the mysql_query() function to execute the SQL statements like above. This function is used to send a query or command to a MySQL connection. Let's see an example:

<?php
$con = mysql_connect("localhost", "adam" ,"ada");
if (!$con)
{
die('Error connecting database');
}
if (mysql_query("CREATE DATABASE my_db", $con))
{
echo "Database successfully created";
}
else
{
echo "Error creating database!";
}
mysql_close($con);
?>


The above example creates a database called "my_db".


Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.