SHARE
TWEET

Untitled

a guest Jun 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ?>
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top