Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = 'localhost:3306'; //database host
- $user = 'root'; //database user
- $pass = ''; //database password
- $dbname = 'mydb2'; //database name
- //Connection to Databse
- $conn = mysqli_connect($host, $user, $pass,$dbname);
- // Check connection
- if(!$conn){
- die('Could not connect: '.mysqli_connect_error());
- }
- echo 'Connected successfully<br/>';
- // Attempt create table query execution
- $sql = "create table emp5(id INT AUTO_INCREMENT,name VARCHAR(20) NOT NULL,
- emp_salary INT NOT NULL,primary key (id))";
- //checking Table creating
- if(mysqli_query($conn, $sql)){
- echo "Table emp created successfully";
- }else{
- echo "Could not create table: ". mysqli_error($conn);
- }
- // Close connection
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement