PHP Operations Database

Source: Internet
Author: User

Create a link
$connect =mysql_connect ("localhost", "root", "123");//("Server name" " native user name" "Password")

Select the database to manipulate
mysql_select_db ("* * *", $connect);//Database name,
Write SQL statements
$sql = "SELECT * from Nation";//The table name must exist

$sql = "INSERT into nation values (' n003 ', ' Miao ')";//Database increase

Execute SQL statement, return result set
$result =mysql_query ($sql);
Reading data from the result set
Var_dump (Mysql_fetch_row ($result));

Remove all results
while ($attr =mysql_fetch_row ($result));
{
Var_dump ($ATTR);
}

[returns the index added by column name]
while ($attr =mysql_fetch_array ($result));
{
Var_dump ($ATTR);
}

[Query field]
while ($attr =mysql_fetch_field ($result));
{
Var_dump ($ATTR);
}

[Return Object]
while ($attr =mysql_fetch_object ($result));
{
Var_dump ($ATTR);
}

How to solve Chinese garbled characters
1. When establishing a database, the character set selection Utf-8
My.ini "Mysqld" in the 2.mysql configuration file and finally add Character_set_server=utf8
3. Modify the page encoding format to Utf-8
Header ("Content-type:text/html;charset=utf-8");

PHP Operational 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.