Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. $host = 'localhost:3306'; //database host
  3. $user = 'root'; //database user
  4. $pass = ''; //database password
  5. $dbname = 'mydb2'; //database name
  6.  
  7. //Connection to Databse
  8. $conn = mysqli_connect($host, $user, $pass,$dbname);
  9. // Check connection
  10. if(!$conn){
  11. die('Could not connect: '.mysqli_connect_error());
  12. }
  13. echo 'Connected successfully<br/>';
  14.  
  15. // Attempt create table query execution
  16. $sql = "create table emp5(id INT AUTO_INCREMENT,name VARCHAR(20) NOT NULL,
  17. emp_salary INT NOT NULL,primary key (id))";
  18. //checking Table creating
  19. if(mysqli_query($conn, $sql)){
  20. echo "Table emp created successfully";
  21. }else{
  22. echo "Could not create table: ". mysqli_error($conn);
  23. }
  24.  
  25. // Close connection
  26. mysqli_close($conn);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement