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