Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Defining the Host, Usernme and Password
- DEFINE("host", "localhost");
- DEFINE("username", "root");
- DEFINE("password", "");
- DEFINE("database", "dbtest");
- // Creating connection
- $conn = mysqli_connect(host, username, password, database);
- // Checking connection
- if ($conn) {
- echo "Connected successfully";
- $sql = "INSERT into table_name (c1, c2, c3) VALUES (v1, v2, v3)"; // C is for column and V is for value
- if ($conn->query($sql) === TRUE) { // Executing the query
- echo "Table created";
- } else {
- echo "Failed to create table: " . $conn->error;
- }
- }else{
- // Displaying an error if the connection failed...
- echo "Connection Failed".mysqli_connect_errror();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement