Today I'm going to explain about how to connect to database using PHP and how to create databases etc
First connect to localhost
mysql_connect("localhost","username","password") or die(mysql_error());
second:create a database
$query=mysql_query("CREATE DATABASE databasename");
if($query)
{
echo "database created";
}
else
{
die(mysql_error());
}
Now we can create table under database
$query1=mysql_query("CREATE TABLE tablename(column_name datatype definition1 definition2,column_name datatype definition1 definition2");
if($query1)
{
echo "table createed";
}
else
{
die(mysql_error());
}
First connect to localhost
mysql_connect("localhost","username","password") or die(mysql_error());
second:create a database
$query=mysql_query("CREATE DATABASE databasename");
if($query)
{
echo "database created";
}
else
{
die(mysql_error());
}
Now we can create table under database
$query1=mysql_query("CREATE TABLE tablename(column_name datatype definition1 definition2,column_name datatype definition1 definition2");
if($query1)
{
echo "table createed";
}
else
{
die(mysql_error());
}