0% found this document useful (0 votes)
11 views

SQL insert php

Uploaded by

humaawaz1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

SQL insert php

Uploaded by

humaawaz1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?

php

// Database configuration

$servername = "localhost"; // Change this to your database host if it's different

$username = "root"; // Change this to your database username

$password = ""; // Change this to your database password

$database_name = "parii_database"; // Change this to your database name

// Create a connection to the database server

$conn = new mysqli($servername, $username, $password, $database_name);

// Check the connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

// Sample data to be inserted into the 'users' table

$username = "John Doe";

$email = "johndoe@example.com";

// SQL query to insert data into the 'users' table

$sql = "INSERT INTO users (username, email) VALUES ('$username', '$email')";

// Check if the insertion was successful

if ($conn->query($sql) === TRUE) {

echo "New record inserted successfully";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

// Close the connection

$conn->close();
?>

You might also like