Posted by: sumn03cse | December 17, 2008

How to Connect, Create and interact with mysql and php

it is very easy to connect with php and mysql. Just know about the following function .1. mysql_connect();

2.mysql_query(); and

3. mysql_select_db();

The following example will may help you about that

<?php
// To Connect with Database
$sumn = mysql_connect(“localhost“,”sumon“,”");

// Create database
if (mysql_query(“CREATE DATABASE db_sumn“,$sumn))
{

echo Hurray Database created Let us involve myself as   programmer“;
}

// Create table

mysql_select_db(“db_sumn“, $sumn);
$sql = “CREATE TABLE Persons(FirstName varchar(15),LastName varchar(15),Age int)“;

// Execute query
mysql_query($sql,$sumn);

mysql_close($sumn);
?>

Just Copy and past this at your Editor and show

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.