时间:2021-07-01 10:21:17 帮助过:8人阅读
$conn = mysql_connect("localhost","test","test");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
//mysql_query("set test 'utf8'");
mysql_set_charset("utf8" , $conn);
//选择数据库
mysql_select_db("test", $conn);
//往表里插数据
mysql_query("INSERT INTO test (id, myusername)
VALUES (2,'中文2')");
//mysql_query("INSERT INTO user (id, myusername)
//VALUES (". intval($str_id) . "," . $str_name . ")");
//关闭数据库连接
mysql_close($conn);