PHP 板


LINE

看板 PHP  RSS
※ 引述《buganini (霸格尼尼)》之铭言: : ※ 引述《kingmin (高手)》之铭言: : : 这是我的phpMyAdmin画面 : : http://img543.imageshack.us/img543/5405/20101009120719.jpg
: : 这是我的资料表 : : http://img269.imageshack.us/img269/3784/20101009120743.jpg
: : 这是我的资料表里的结构 : : http://img704.imageshack.us/img704/3241/20101009120809.jpg
: : 我PHP已全部改成utf8并设定无BOM : : PHP里面也有加入了mysql_query("SET NAMES 'utf8'"); : : 请问现在PHP从 因该是BIG5的 MYSQL里取出的资料会变成乱码 : 应 : 那怎麽charset/collation全都是utf-8 ? : : 不过我测试 : : INSERT INTO `search` (`ip` ,`name` ,`time` ,`code` )VALUES ('127.0.0.1', : : 'Guest' , 1286598087 , '中文测是' ); : 试 : : 从phpMyAdmin里看到的是中文 : : 所以显示出网页也是中文没问题 : : 请问如果我想把资料库改用UTF8 : (A) : 如果你用phpmyadmin看资料库内容都正确的话 : 没意外的话应该本来就是罗 : : 并且用CurlRequest从外部更新资料库的资料 : : 可是资料库里中文都不见了 变成是空的 : : 如果PHP里面改成mysql_query("SET NAMES 'big5'"); : : 在从外部更新资料库的资料 在从phpMyAdmin里看到的就是中文 : 这样看起来是资料库存UTF-8, 网页用Big5 : : 不过PHP上看到的就变成乱码了??? : : 请问如何设定才能存入资料是BIG5 取出资料是UTF8 : 有这个必要吗? 为什麽还要用Big5 ? : 除非你的资料库要跟别人的程式共用 : 如果是这样的话那之後再说 : 可是怎麽跟(A)那边的说法不同?? 这是连结资料库 function DB($v_host, $v_database, $v_user, $v_password){ mysql_connect($v_host,$v_user,$v_password) or die("无法连结服务器"); mysql_query("SET NAMES 'utf8'"); if(!mysql_select_db($v_database)){mysql_query("CREATE DATABASE `$v_database`");} mysql_select_db($v_database) or die("无法打开打开数据库"); } 这CURL应该跟网路上找的道程式码的差不多 class CurlRequest{ private $ch; public function init($params) { $this->ch = curl_init(); $proxy=trim($params['proxy']); $user_agent1 = array('Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-TW; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)','Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)'); $rand=rand(0,4); $user_agent = $user_agent1[$rand]; $header = array( "Accept: */*", "Accept-Language: ru-ru,ru;q=0.7,en-us;q=0.5,en;q=0.3", "Accept-Charset: UTF-8,windows-1251;q=0.7,*;q=0.7", "Keep-Alive: 300"); if (isset($params['host']) && $params['host']) $header[]="Host: ".$host; if (isset($params['header']) && $params['header']) $header[]=$params['header']; @curl_setopt ( $this -> ch , CURLOPT_RETURNTRANSFER , 1 ); @curl_setopt ( $this -> ch , CURLOPT_VERBOSE , 1 ); @curl_setopt ( $this -> ch , CURLOPT_HEADER , 1 ); if ($params['method'] == "HEAD") @curl_setopt($this -> ch,CURLOPT_NOBODY,1); @curl_setopt ( $this -> ch, CURLOPT_FOLLOWLOCATION, $params['location']); @curl_setopt ( $this -> ch , CURLOPT_HTTPHEADER, $header ); if ($params['referer']) @curl_setopt ($this -> ch , CURLOPT_REFERER, $params['referer'] ); @curl_setopt ( $this -> ch , CURLOPT_USERAGENT, $user_agent); if ($params['cookie']) @curl_setopt ($this -> ch , CURLOPT_COOKIE, $params['cookie']); if ( $params['method'] == "POST" ){ curl_setopt( $this -> ch, CURLOPT_POST, true ); curl_setopt( $this -> ch, CURLOPT_POSTFIELDS, $params['post_fields'] ); } if (!empty($proxy)){ curl_setopt( $this -> ch, CURLOPT_PROXY, $proxy);$proxy1=$proxy;} @curl_setopt ( $this -> ch, CURLOPT_URL, $params['url']); @curl_setopt ( $this -> ch , CURLOPT_SSL_VERIFYPEER, 0 ); @curl_setopt ( $this -> ch , CURLOPT_SSL_VERIFYHOST, 0 ); if (isset($params['login']) & isset($params['password'])) @curl_setopt($this -> ch , CURLOPT_USERPWD,$params['login'].':'.$params['password']); @curl_setopt ( $this -> ch , CURLOPT_TIMEOUT, $params['timeout']); } public function exec() { global $debug1,$nn,$proxy,$proxy1; $response = curl_exec($this->ch); $error = curl_error($this->ch); $result = array( 'header' => '', 'body' => '', 'curl_error' => '', 'http_code' => '', 'last_url' => ''); if ( $error != "" ){ $result['curl_error'] = $error; return $result; } $header_size = curl_getinfo($this->ch,CURLINFO_HEADER_SIZE); $result['header'] = substr($response, 0, $header_size); $result['body'] = substr( $response, $header_size ); $result['http_code'] = curl_getinfo($this -> ch,CURLINFO_HTTP_CODE); $result['last_url'] = curl_getinfo($this -> ch,CURLINFO_EFFECTIVE_URL); if($debug1){ echo $result['http_code']."<br>".$result['header']."<br><br>".$result['body']."<br>";} if(!empty($proxy1)){ if($result['http_code'] <> "200" and $result['http_code'] <> "302"){updataproxy();}} return $result; } } mysql_query("SET NAMES 'utf8'"); 我也用了这四种//UTF-8 utf8 big5 Big5 还是不行???? --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.115.19.192







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Tech_Job站内搜寻

TOP