Home > Backend Development > PHP Tutorial > How to add data to the database using mysqli in php, phpmysqli_PHP tutorial

How to add data to the database using mysqli in php, phpmysqli_PHP tutorial

WBOY
Release: 2016-07-13 10:02:02
Original
1418 people have browsed it

php uses mysqli to add data to the database, phpmysqli

This article describes the example of php using mysqli to add data to the database. Share it with everyone for your reference. The specific implementation method is as follows:

$mydb = new mysqli('localhost', 'username', 'password', 'databasename');
$sql = "INSERT INTO users (fname, lname, comments)
VALUES ('$_POST[fname]', '$_POST[lname]', '$_POST[comments]')";
if ($mydb->query($sql) == TRUE) {
echo "user entry saved successfully.";
} else {
echo "INSERT attempt failed" ;
}
$mydb->close();
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/970987.htmlTechArticlephp uses mysqli to add data to the database, phpmysqli This article describes how php uses mysqli to add data to the database. . Share it with everyone for your reference. Specific implementation method...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template