<span style=
"color: #000000;"
>php
</span><span style=
"color: #008000;"
>
<span style=
"color: #800080;"
>
$con
</span>=<span style=
"color: #008080;"
>mysqli_connect</span>(
"localhost"
,
"root"
,
"123456"
,
"RUNOOB"
<span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span> (<span style=
"color: #008080;"
>mysqli_connect_errno</span>(<span style=
"color: #800080;"
>
$con
</span><span style=
"color: #000000;"
>))
{
</span><span style=
"color: #0000ff;"
>
echo
</span>
"连接 MySQL 失败: "
. <span style=
"color: #008080;"
>mysqli_connect_error</span><span style=
"color: #000000;"
>();
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #008080;"
>mysqli_autocommit</span>(<span style=
"color: #800080;"
>
$con
</span>,<span style=
"color: #0000ff;"
>FALSE</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #008000;"
>
<span style=
"color: #008080;"
>mysqli_query</span>(<span style=
"color: #800080;"
>
$con
</span>,
"<span style="
color: #000000;">INSERT INTO websites (name, url, alexa, country)
VALUES (
'百度'
,
'https://www.baidu.com/'
,
'4'
,
'CN'
)</span>
"<span style="
color: #000000;">);
</span><span style=
"color: #008000;"
>
<span style=
"color: #008080;"
>mysqli_commit</span>(<span style=
"color: #800080;"
>
$con
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #008000;"
>
<span style=
"color: #008080;"
>mysqli_close</span>(<span style=
"color: #800080;"
>
$con
</span><span style=
"color: #000000;"
>);
</span>?>