insert query in mysql 150^

Hello developer in this blog post is the insert query in mysql and i am purity understand is this blog and is this post on the data and mysql databse connection purity,…………

After a database create and verify and a table has been created propely, we can start adding data in the my databse table.

Here are some syntax rules to follow:

  • The SQL query must be use in PHP
  • String values inside the SQL query must be used
  • Numeric values must not be used
  • The word NULL must not be used

The INSERT INTO statement is used to add new records to a MySQL table:

Your Query is:

INSERT INTO table_name (col1, col2, col3,...)
VALUES (val1, val2, val3,...)

Following my rools and get done with you.

The following examples add a new record to the “Users” table:


$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "DATABSE_NAME";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);

$sql = "INSERT INTO Users (first_name, last_name, email_id)
VALUES ('Lara', 'Tuto', '')";

if ($conn->query($sql) === TRUE) {
  echo "Data created successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;

insert query in mysql

i hope your connection and data created successfully………

Leave a Comment