<?php
//一、連接mysql
$dbhost = "localhost:3307"; //服務器
$db = "dataname"; //數據庫
$dbuser = "root"; //用戶名
$dbpass = "*******"; //密碼
$db_qianzhui = "sdb_"; //表前綴
$link = mysql_connect($dbhost,$dbuser,$dbpass);
if(!$link) echo "鏈接失敗!";
else echo "成功!!!";
mysql_query("SET NAMES 'UTF8'");
mysql_query("SET CHARACTER SET UTF8"); //解決亂碼問題
mysql_query("SET CHARACTER_SET_RESULTS=UTF8'");
mysql_select_db("{$db}");
?>
代碼如下 復制代碼 <?php
代碼如下 復制代碼
<?php
//三、以下准備一邊讀一寫入操作!
while(! $rs->eof) {
//$f = $rs->Fields(1); //1.賦值(*調試用)
//echo $f->value; //2.看能不能寫讀出來(*調試用)
//以下是分別給變量賦值,其中'gb2312','utf-8'為了解決亂碼問題!
$id = iconv ('gb2312','utf-8',$rs->Fields(ID)->value); //ID為access字段,或用數字表示
$name = iconv ('gb2312','utf-8',$rs->Fields(title)->value);
$jianjie = iconv ('gb2312','utf-8',$rs->Fields(1)->value);
$content = iconv ('gb2312','utf-8',$rs->Fields(content)->value);
$down = iconv ('gb2312','utf-8',$rs->Fields(download)->value);
echo "<font color=red>".$name."</font>已經插入<br>"; //輸出插入記錄
//依次執行insert,值為變量
$sql="INSERT INTO `shopex`.`sdb_articles` (`article_id`,`node_id`,`title`,`content`,`uptime`,`ifpub`,`align`,`filetype`,`filename`,`orderlist`,`disabled`) VALUES ('','{$fenlei}','{$name}','{$info}','1275549287','1',Null,Null,NULL,NULL,'false')";
//以上是插入MYSQL數據庫的SQL
mysql_query($sql); //執行語句!
///echo $rs->Fields(name)->value. "<br>";
$rs->MoveNext();
//個人用於ACCESS向mysql內轉換數據庫的操作
}
?>