-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
27 lines (24 loc) · 852 Bytes
/
database.php
File metadata and controls
27 lines (24 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
$conn = mysql_connect("localhost","root","") or die(mysql_error());
$sql = "CREATE DATABASE IF NOT EXISTS StudentDB";
if(mysql_query($sql , $conn)){
echo "Database Created Succesfully" ."</br>";
}
else{
echo "Error creating database" ."</br>". mysql_error($conn);
}
mysql_select_db("StudentDB" , $conn);
$sql1 = "CREATE TABLE IF NOT EXISTS studentDetails(
id int(11) UNIQUE,
username varchar(30) NOT NULL,
email varchar(30) NOT NULL,
password varchar(20) NOT NULL,
course varchar(20) NOT NULL,
year int(5) NOT NULL,
mobile bigint(10) NOT NULL)";
if ( mysql_query($sql1,$conn))
echo "Table created Succesfully" ."</br>";
else
echo "Error creating Table"."</br>". mysql_error($conn);
mysql_close($conn);
?>