Advertisement
Guest User

Untitled

a guest
Jul 15th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $server = 'localhost';
  2. $user = 'root';
  3. $pass = '';
  4.  
  5. $conn = mysqli_connect($server, $user, $pass);
  6.  
  7. if (!$conn){
  8. echo "Failed to connect to Server";
  9. }else{
  10. echo "Connected";
  11. }
  12.  
  13. $sql = 'CREATE DATABASE college';
  14. $table = 'CREATE TABLE students(
  15. student_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  16. student_name VARCHAR(255) NOT NULL,
  17. student_email VARCHAR(255) NOT NULL,
  18. student_city VARCHAR(255) NOT NULL,
  19. )';
  20.  
  21. if(mysqli_query($conn,$sql)){
  22. echo"Database created";
  23. }else{
  24. echo 'Failed to create Database';
  25. };
  26.  
  27. if(mysqli_query($conn,$table)){
  28. echo "Table Created";
  29. }else{
  30. echo "Failed to create Table";
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement