Wednesday, October 31, 2012

MySQL Tutorials

Create a Connection to a MySQL Database
Before you can access data in a database, you must create a connection to database.
In PHP, this is done with the mysql_connect()

Syntax
Mysql_connect(servername, username, password);

For Example:
$con=mysql_connect(“localhost”,”peter”,”abc123”);
If(!$con){
Die(‘Could not connect:’.mysql_error());
}

?>


Create a Database:
The CREATE DATABASE statement is used to create a database in MySQL.

Syntax:
CREATE DATABASE database_name

Create a Table:

The Create TABLE statment is used to create a table in MySQL.

Syntax:
CREATE TABLE table_name(

column_name1 data_type,
column_name2 data_type,
column_name3 data_type,


)
 

No comments:

Post a Comment