簡單學習PHP向MYSQL中插入數據的代碼
<?php
$dbhost = localhost;
$dbuser = webjxcom; //你的mysql用戶名
$dbpass = 123456; //你的mysql密碼
$dbname = database; //你的mysql庫名
//連接本地數據庫
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if ($conn) {
echo "連接數據庫成功";
} else {
echo "連接數據庫失敗";
}
//打開數據庫
mysql_select_db($dbname,$conn);
//插入數據
$sql="insert into test(test) values(ddddddd)";
$result=mysql_query($sql,$conn)or die(mysql_error());
echo "打開數據庫";
//關閉數據庫
mysql_close($conn);
?>