connection.inc.php :
<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
{echo '<br>host coonected<br>';}
else
{
die('Could not connect ');
}
?>
creation_table.php :
<?php
require 'connection.inc.php';
if (mysql_select_db('test'))
echo '<br>database selected<br>';
if(mysql_query("create table test(sno varchar(3),name varchar(15))",$con))
{
echo "<br>table created<br>";
}
else
{
echo '<br><br>table not created :'.mysql_error();
}
mysql_close($con);
?>
run " creation_table.php"
output :
host coonected
database selected
table created
<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
{echo '<br>host coonected<br>';}
else
{
die('Could not connect ');
}
?>
creation_table.php :
<?php
require 'connection.inc.php';
if (mysql_select_db('test'))
echo '<br>database selected<br>';
if(mysql_query("create table test(sno varchar(3),name varchar(15))",$con))
{
echo "<br>table created<br>";
}
else
{
echo '<br><br>table not created :'.mysql_error();
}
mysql_close($con);
?>
run " creation_table.php"
output :
host coonected
database selected
table created