Dear all,
I new to PHP/MySql.
here i am trying to create a database.
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
die('connected......'.mysql_error());
}
// create Database
if (mysql_query("CREATE DATABASE my_db",$con))
{
die('Database created......'.mysql_error());
// echo "Database created";
}
else
{
die('Error creating database: ' . mysql_error());
// echo "Error creating database: " . mysql_error();
}
// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";
// Execute query
mysql_query($sql,$con);
mysql_close($con);
?>
1. I couldn't identify that whats done. In PHPMyAdmin there is no database with name "my_db".
2. I could see only one message on my page the "connected......" which is from line no: 9. if the CREATE DATABASE is unsucess then the other message "Error creating database:" should be displayed.
Regards:
Muhammad Nadeem