Simply learn PHP's code to insert data into MySQL _php tutorial

Source: Internet
Author: User
Tags learn php

Simply learn PHP's code to insert data into MySQL

$dbhost = localhost;
$dbuser = webjxcom; Your MySQL user name
$dbpass = 123456; Your MySQL password
$dbname = database; Your MySQL library name

Connecting to a local database
$conn = mysql_connect ($dbhost, $dbuser, $dbpass);
if ($conn) {
echo "Connection to database Success";
} else {
echo "Failed to connect to database";
Open Database
mysql_select_db ($dbname, $conn);
Inserting data
$sql = "INSERT INTO test (test) VALUES (DDDDDDD)";
$result =mysql_query ($sql, $conn) or Die (Mysql_error ());

echo "Open database";
Close the database
Mysql_close ($conn);
?> true techarticle simply learn PHP's code to insert data into mysql? php $dbhost = localhost; $dbuser = webjxcom;//your mysql username $dbpass = 123456;//your MySQL password $dbname = database; Your ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.