Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. // Defining the Host, Usernme and Password
  3. DEFINE("host", "localhost");
  4. DEFINE("username", "root");
  5. DEFINE("password", "");
  6. DEFINE("database", "dbtest");
  7. // Creating connection
  8. $conn = mysqli_connect(host, username, password, database);
  9. // Checking connection
  10. if ($conn) {
  11. echo "Connected successfully";
  12. $sql = "INSERT into table_name (c1, c2, c3) VALUES (v1, v2, v3)"; // C is for column and V is for value
  13.  
  14. if ($conn->query($sql) === TRUE) { // Executing the query
  15. echo "Table created";
  16. } else {
  17. echo "Failed to create table: " . $conn->error;
  18. }
  19. }else{
  20. // Displaying an error if the connection failed...
  21. echo "Connection Failed".mysqli_connect_errror();
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement