Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2. $host = 'localhost:3306'; // Host Address
  3. $user = 'root'; // DataBase User
  4. $pass = ''; // DataBase Password
  5. $dbname = 'mydb2';//DataBase name
  6.  
  7. // Connecting the DataBase
  8. $conn = mysqli_connect($host, $user, $pass,$dbname);
  9.  
  10. //Checking the Connection
  11. if(!$conn){
  12. die('Could not connect: '.mysqli_connect_error());
  13. }
  14. echo 'Connected successfully<br/>';
  15.  
  16. // Inserting data into the table
  17. $sql = 'INSERT INTO emp5(name,emp_salary) VALUES ("sonoo", 9000)';
  18.  
  19. //Checking the Inserted the Data
  20. if(mysqli_query($conn, $sql)){
  21. echo "Record inserted successfully";
  22. }else{
  23. echo "Could not insert record: ". mysqli_error($conn);
  24. }
  25.  
  26. //connection close
  27. mysqli_close($conn);
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement