PHP杩炴帴MSSQL鐨勯棶棰榑PHP鏁欑▼ | 甯涔嬪
[php]
if (function_exists('mssql_connect')){
echo '鏈嚱鏁板瓨鍦紝璇存槑鐜鏀寔MSSQL';
}else{
echo '浣犵殑鐜涓嶆敮鎸丮SSQL锛岃鍘籄PACHE涓厤缃?#39;;
}
if (function_exists('mssql_connect')){
echo '鏈嚱鏁板瓨鍦紝璇存槑鐜鏀寔MSSQL';
}else{
echo '浣犵殑鐜涓嶆敮鎸丮SSQL锛岃鍘籄PACHE涓厤缃?#39;;
}褰揚HP鐜涓嶆敮鎸佹椂璇峰厛瀹変互涓嬬殑鏂规硶杩涜鐜鐨勯厤缃?/p>
1銆佹墦寮€浣犵殑PHP.INI閰嶇疆鏂囦欢锛屾妸extension=php_pdo_mssql.dll鍜宔xtension=php_mssql.dll鍓嶉潰鐨?ldquo;;”鍘绘帀锛屽敖閲忔壘鍒板拰mssql鐩稿叧鐨勫瓧鐪硷紝閮芥妸浠栧惎鐢紱
2銆佷綘鐨勮繍琛岀幆澧冧腑涓嶄竴瀹氭湁杩炴帴MSSQL鐨勮繛鎺ュ簱锛屾墍浠ヤ綘蹇呴渶妫€鏌ヤ竴涓嬩綘鐨凱HP鐩綍涓嬫槸鍚﹀瓨鍦╡xt鐩綍涓嬬殑php_mssql.dll鍜宯twdblib.DLL锛岀綉涓婃湁鏂囩珷璇撮渶瑕丆OPY鍒癢INDOWS/SYSTEM32鐩綍涓嬶紝 濡傛灉杩炴帴涓嶄笂鐨勮瘽鍙互璇曚竴涓嬶紱
3銆侀噸鍚竴涓婣PACHE锛屽啀涓嶈浣犲氨鏁翠釜鏈哄瓙閲嶅惎锛堟湁鏃跺€欏氨鏄繖涔堝彉鎬侊級銆?/p>
鍋氬畬涓婇潰鐨?姝ュ悗涓嶈浠ヤ负瀹屾垚浜嗭紝鍙互鎼炲畾PHP+MSSQL浜嗭紝鍚庨潰杩樻湁瀛楃闆嗙殑闂銆?/p>
[php]
mssql_select_db($db_name,$conn);
$sql="INSERT INTO contacts (ID,MemberNo,Name,CustomerStateID,Ext,Phone,Mobile,email,QQ,Gender,Company,Province_ID,City_ID,Address,Postalcode) VALUES (4,'BX4','鍒樺姜',1,'','','13924007557','','153216429','鐢?#39;,'鍗庡悍淇濋櫓浠g悊鏈夐檺鍏徃骞夸笢鍒嗗叕鍙?#39;,0,0,'骞垮窞甯傝秺绉€鍖鸿揪閬撹矾5鍙峰箍宸炲啗鍖烘湇鍔′腑蹇冨ぇ鍘?妤?#39;,'510035')";
$sql=iconv('utf-8','gb2312',$sql);//杩欎釜杞崲蹇呴渶锛屽鏋滀綘鐨勭紪鐮佹槸涓€鑷寸殑璇濊繕濂藉姙锛屾垜灏辨槸鍦ㄨ繖涓棶棰樹笂绾犵粨浜嗗緢涔?nbsp;
$query=mssql_query($sql,$conn);
mssql_select_db($db_name,$conn);
$sql="INSERT INTO contacts (ID,MemberNo,Name,CustomerStateID,Ext,Phone,Mobile,email,QQ,Gender,Company,Province_ID,City_ID,Address,Postalcode) VALUES (4,'BX4','鍒樺姜',1,'','','13924007557','','153216429','鐢?#39;,'鍗庡悍淇濋櫓浠g悊鏈夐檺鍏徃骞夸笢鍒嗗叕鍙?#39;,0,0,'骞垮窞甯傝秺绉€鍖鸿揪閬撹矾5鍙峰箍宸炲啗鍖烘湇鍔′腑蹇冨ぇ鍘?妤?#39;,'510035')";
$sql=iconv('utf-8','gb2312',$sql);//杩欎釜杞崲蹇呴渶锛屽鏋滀綘鐨勭紪鐮佹槸涓€鑷寸殑璇濊繕濂藉姙锛屾垜灏辨槸鍦ㄨ繖涓棶棰樹笂绾犵粨浜嗗緢涔?br />
$query=mssql_query($sql,$conn);濡傛灉涓嶄笂iconv杞崲锛屼笉鍚岀殑缂栫爜浼氶€犳垚mssql_query杩斿洖false,鎴戝凡缁忎娇鐢ㄤ簡@mssql_query("SET NAMES UTF8",$conn);杩涜杞崲锛屾殏鏃朵笉鐭ラ亾涓轰粈涔堜笉琛岋紝鎵€浠ユ墍鏈夌殑SQL璇彞閮借缁忚繃杞崲銆?/p>
瀹屾垚涓婇潰鐨勫熀鏈槸鍙互瀵规暟鎹簱杩涜鎿嶄綔浜嗐€?/p>