PHP functions and MySQL Database

Source: Internet
Author: User

SQL Language Basics

The basic syntax of <1>mysql
Naming: For databases, tables, records, fields, indexes, and aliases. Consisting of letters, numbers, underscores, and $, four characters can be used in the name of the first character, the sheer number cannot do the name
Case: Aliases are case-sensitive, UNIX, database and table names (as files exist) are case-sensitive, Windows is not distinguished; fields, indexes, function names and keywords are not case-sensitive

<2>mysql Data types

<3>mysql SQL statements Daquan

MySQL operation in PHP
Note: Standard SQL is not a program language, just a database interactive instruction. So SQL has to rely on other programming languages (this is PHP) to complete the procedural tasks

//log in to the MySQL database with the parameters: Hostname,username,password. Login successful return login number (link_identifier), failure returns false$connect =mysql_connect ('localhost','Root','123456') or Die ("Unable to connect to database");//After the previous function execution fails, the following function is executed//Select database, database XSGL exists return ture$Select=mysql_select_db ("XSGL", $connect);//There are two send query functions$result [email protected] mysql_db_query ("MySQL","SELECT * from user"the function has 3 parameters: database name, SQL statement, and [Link_identifier] when it is update, INSERT, and DELETE statements, the return may be true or false; When a SELECT statement returns a new ID value ( The action handle for the query result). When False is returned, one case is successful execution but no return value, and the other is a query string with an error. intmysql_query (stringQueryint[Link_identifier]);//The database needs to be specified with mysql_select_db ()//function to read data in MySQL database$row =mysql_fetch_array ($result); the function splits query results (result) into array variables. Returns an array that can be accessed either by an array's subscript, or by using the Data table field name to access array mysql_fetch_row (intResultint[Result_typ]);//the returned array can only be accessed with the data subscript//exit MySQL database with parameter link_identifier, return ture successfully, otherwise falseClose=mysql_close ($connect);

Using DOS commands in a Windows environment

net start MySQL   / / start MySQL server //  MySQL client program mysql.exe connection database server default hostname localhost, default User name Unix login (root or other) or Odbs (Windows)123456 use database name;   // Select the MySQL management database and omit the database name for the current database operation // The newly created database exists as a directory in the Mysql/data directory, in which 3 files are created for each table, the table structure is recorded, the index and the data contents are quit;  // Disconnect the client program from the database server net stop MySQL   // shut down the database server if necessary

PHP functions and MySQL Database

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.