Solution:
Step 1: Create Database
Code
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (mysql_query("CREATE DATABASE ABC",$con))
{
echo "Your Database created !!";
}
else
{
echo "Error creating database: " . mysql_error();
}
mysql_close($con);
?>
Step 2: Create Table
Code
<?php
$con = mysql_connect ("localhost","root","");
if (!$con)
{
die ('Could not connect: ' . mysql_error());
}
mysql_select_db ("ABC", $con);
$sql = "CREATE TABLE employee
(
name VARCHAR( 50 ) ,
sex VARCHAR( 50 ) ,
)";
mysql_query($sql,$con);
echo "Your Table Created !!";
mysql_close($con);
?>
Top comments (4)
Please do not use
mysql_*
functions. Doing so is insecure due to the nature of the library. It also means using an unsupported version of PHP.The
mysql_*
library was removed in PHP 7. At worst this should be replaced withmysqli_*
functions.Really, it should use a parametised queries to reduce the risks of SQL injection.
Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link. Doing so helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section.
If you choose to do so, you also have the option to add a canonical URL directly to your post.
sure i will take care of that
Please don't write just for the sake of writing, don't publish poor quality articles.