I have created a simple tables with two fields through phpmyadmin and mysqlconsole. But when i am trying to do same thing through php code i fail though i know the code.
- Code: Select all
<!DOCTYPE html>
<html>
<body>
<?php
// checking connection
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
echo"connection ok";
}
//create database
if( mysql_query("CREATE DATABASE tutorial",$con))
{
echo"database created";
}
else
{
echo"problem is creation of database".mysql_error();
}
//create table
mysql_select_db("tutorial", $con);
mysql_query ( "CREATE TABLE jak
(
name varchar(15),
age int(3),
e.mail varchar(20),
)
mysql_close($con);
?>
</body>
</html>


