Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

create a php database connection

<?php
 
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";
 
// Create connection
$conn = new mysqli($servername,
    $username, $password, $dbname);
 
// Check connection
if ($conn->connect_error) {
    die("Connection failed: "
        . $conn->connect_error);
}
 
$sqlquery = "INSERT INTO table VALUES
    ('John', 'Doe', 'john@example.com')"
 
if ($conn->query($sql) === TRUE) {
    echo "record inserted successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
?>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #create #php #database #connection
ADD COMMENT
Topic
Name
6+9 =