Easy To Learning
  • Login
  • Sign Up
  • Q&A
  • Home
  • Php Tutorial
  • MySql Tutorial
  • Object-Oriented Programming
  • Java Tutorial
  • HTML Tutorial
  • React JS Tutorials
  • Free Projects
  • Blogs & Articles
  • Others
    • About Us
    • Contact Us
MySQLi Insert Using PHP
Easy To Learning

Education Needs Complete Solution

Online Ask Question Question And Answer
  1. Home
  2. MySql Tutorials
  3. MySQLi Insert Using PHP

MySql Tutorial

Basic MySql Tutorials

  • MySql Table Content
  • MySQL Introduction
  • MySQL Constraints
  • MySQL Connection In PHP
  • MySQL Create Database In PHP
  • MySQL Create Table using PHP
  • MySQL Insert Using PHP
  • MySQL Update Using PHP
  • MySQL Delete Using PHP
  • MySQL Select Using PHP
  • MySQL Order By Using PHP
  • MySQL Where Clause Using PHP
  • MySQL Fetch Array Using PHP
  • MySQL Fetch Assoc Using PHP
  • MySQL Fetch Row Using PHP
  • MySQL Fetch Object Using PHP
  • MySQL Basic Queries

Basic MySqli Tutorials

  • MySQLi Connection In PHP
  • MySQLi Create Database In PHP
  • MySQLi Create Table using PHP
  • MySQLi Insert Using PHP
  • MySQLi Update Using PHP
  • MySQLi Delete Using PHP
  • MySQLi Select Using PHP
  • MySQLi Order By Using PHP
  • MySQLi Where Clause Using PHP
  • MySQLi Fetch Array Using PHP
  • MySQLi Fetch Assoc Using PHP
  • MySQLi Fetch Row Using PHP
  • MySQLi Fetch Object Using PHP
  • MySQLi Predefined Function In PHP

MySQLi Insert Using PHP

The INSERT INTO statement is used to add new records to a database table. The insert statement is used to add new records to a database table. each time a new record is to be added we use INSERT INTO statement for that purpose. There are two ways of inserting records either explicitly providing the column name with values respectively or simply by providing values of the table but doesn't specify the column name.

Syntax rules to follow:

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

Syntax

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

INSERT INTO table_name (column1, column2, column3,...)VALUES (value1, value2, value3,...)

PHP MySQLii Insert Record Example

<?php  
	$host = "localhost";  
	$user = "";  
	$pass = "";  
	$dbname = "users";  
	  
	$conn = mysqli_connect($host,$user,$pass,$dbname) or die(mysqli_error());  

	$sql = "INSERT INTO users(name,salary) VALUES ('suhail','90000')"; 

	if(mysqli_query($conn,$sql)){  
	  echo "Record inserted successfully";  
	}else{  
		echo "Could not insert record: ". mysqli_error();  
	}  
	mysqli_close();  
?>  

Output:

Record inserted successfully

 

Series: MySql Tutorials Hub
All Topics
Free Download Projects
Previous Chapter
Next Chapter

Ask a Question

Have a coding query or doubt? Ask here and get help from our community.

500 characters remaining
Submitting...
Free Download Projects
Join Telegram Group Join WhatsApp Group
Related Topics:
how to insert data in phpmyadmin using php php mysqli insert how to create an html form that stores data in a mysqli database using php how to insert data into mysqli db using form in php database how to insert data in mysqli using php how to store form data in database using php how to save data from html form to a database using php store data from html form to database

Member Sign In

Forgot?
Signing in...

Don't have an account? Register here

Create Free Account

Register Captcha
Registering...

Already have an account? Sign In

Ask a Question

500 characters remaining
Submitting...

About Easy To Learning

Easy To Learning is a comprehensive programming learning portal offering free, practical, developer-driven tutorials for PHP, Java, Python, Spring, MySQL, CSS, Bootstrap, CakePHP, and more.

Explore community-contributed questions and answers, and download ready-to-run source code projects.

Quick Links

  • Home
  • Questions & Answers
  • Download Projects
  • Blog & Articles
  • Member Login

Community

  • Telegram Group
  • WhatsApp Community
  • Ask a Question
  • Join as Member

Connect With Us

Stay updated with our newest programming tutorials and free open source projects.

© 2026 Easy To Learning. All Rights Reserved.