MySQL Learning note--5.php operation MySQL

Source: Internet
Author: User

1. Connect

① using MySQL's mysql_connect to connect

$conn = mysql_connect (' host ', ' User ', ' password ');

Note: If the MySQL port is set to 3307

Then mysql_connect ("localhost:3307", "User", "password")

$sql = ' Use library name ';

mysql_query ($sql, $conn);

mysql_query ("SET NAMES UTF8");

② Other Connection methods

You can also use mysqli and PDO

Process-oriented notation for mysql_connect series functions

And Mysqli is to encapsulate the function of MySQL into class, it is object-oriented notation

And PDO is a unified database interface, which blocks the database

Inconsistencies (such as Oracle, SQL Server ...)

That is, using PDO to connect, even if the database is replaced, can also be run

PDO is also an object-oriented notation

2. Database functions

Mysql_query (); Execute SQL statement

Mysql_fetch_assoc (); Get results from resources as associated data

Mysql_error (); Output MSSQL error message

@zhnoah
Source: http://www.cnblogs.com/zhnoah/
This article is owned by me and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original
The right to pursue legal liability.

MySQL Learning note--5.php operation MySQL

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: info-contact@alibabacloud.com 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.