◆ mysql数据库教程默认的编码是utf8,如果这种编码与你的php网页不一致,可能就会造成mysql乱码;
◆ mysql中创建表时会让你选择一种编码,如果这种编码与你的网页编码不一致,也可能造成mysql乱码;
◆ mysql创建表时添加字段是可以选择编码的,如果这种编码与你的网页编码不一致,也可能造成mysql乱码;
◆ 用户提交页面的编码与显示数据的页面编码不一致,就肯定会造成php页面乱码;
◆ 如用户输入资料的页面是big5码, 显示用户输入的页面却是gb2312,这种100%会造成php页面乱码;
◆ php页面字符集不正确;
◆ php连接mysql数据库语句指定的编码不正确。
注意:很多人都怀疑mysql版本不一致会导致乱码,相信看了本说明你就不会这样认为了。
平时你在某些网站看到的文字可能有几种编码, 如你看到一个繁体字,它有可能是big5编码,也有 可能是utf-8编码的,更有可能是gb码的,没错,也就是说有简体编码的繁体字,也有繁体编码的简体字,一定要了解这一点。
如果你是做一个简体编码的网页,编码定为gb2312,如果有香港和台湾地区的访客提交繁体的信息,就可能会造成乱码,解决方法:
将网站编码设为 utf-8,这样可以兼容世界上所有字符。
如果网站已经运作了好久,已有很多旧数据,不能再更改简体中文的设定,那么建议将页面的编码设为 gbk, gbk与gb2312的区别就在于:gbk能比gb2312显示更多的字符,要显示简体码的繁体字,就只能用gbk。
使用mysql+php产生乱码的原因都了解得很清楚了,那么解决就不困难了。
mysql+php产生乱码的解决办法:
如果安装mysql的编码已不能更改,很多朋友是购买虚拟主机建立网站,无权更改mysql的安装编码,这一关我们可以跳过,因为只要后面的步聚正确,一样能解决乱码问题。
修改数据库编码,如果是数据库编码不正确,可以在phpmyadmin 执行如下sql代码:alter database 'test' default character set utf8 collate utf8_bin
以上命令就是将test数据库的编码设为utf8。
修改表的编码,sql代码:alter table 'category' default character set utf8 collate utf8_bin
以上命令就是将一个表category的编码改为utf8。
修改字段的编码,sql代码:
(1)、alter table 'test' change 'dd' 'dd' varchar( 45 ) character
(2)、set utf8 collate utf8_bin not null
以上命令就是将test表中dd的字段编码改为utf8。
如果是这种情况容易解决,只需检查下页面,修改源文件的charset即可,这种情况也是修改页面charset即可,在连接数据库的语句中。
sql代码:
- mysql_connect('localhost','user','password');
- mysql_select_db('my_db');
- mysql_query("set names utf8;"); //select 数据库之后加多这一句
为了避免php页面乱码的发生,php页面开始第一句php代码
- header("content-type:text/html; charset=utf-8"); //强行指定页面的编码,以避免乱码
注意:照以上方法修改以后只能保证你新插入的数据不会乱码,举个例:如果你用户已提交的数据是big5,你却想通过以上方法改为可以在gb2312的网页正确显示是不可能的, 这种文字内码的变换只能通过另写程序来解决。
波比源码 » MySQL+PHP产生乱码原因分析与解决方法
levaquin order levaquin medication
acillin usa order cephalexin 500mg pill order erythromycin 500mg online
oral sildenafil order bimatoprost online purchase robaxin generic
order suhagra online cheap sildenafil australia estradiol without prescription
isotretinoin pills buy isotretinoin 20mg generic order zithromax 500mg pill
tadalafil generika tadalafil 20mg für männer sildenafil 50mg für männer
generic modafinil 100mg Cialis in usa acetazolamide for sale
clonidine without prescription catapres 0.1mg pills order tiotropium bromide generic
buspar online buy buy oxybutynin 5mg generic buy oxybutynin 2.5mg online cheap
order terazosin generic buy arava 20mg generic sulfasalazine 500mg without prescription
bupropion 150 mg pill buy strattera 10mg for sale seroquel 100mg uk
buy molnupiravir 200mg online cheap naprosyn 500mg usa buy lansoprazole generic
zoloft without prescription Canadian pharmacy viagra legal sildenafil tablet
order tadalafil for sale generic viagra in denver viagra 100mg tablet
avlosulfon pills buy perindopril generic aceon 4mg usa
medroxyprogesterone cheap order praziquantel 600 mg order periactin 4mg pills
azithromycin pills buy azithromycin 250mg generic buy neurontin 100mg online
buy generic olanzapine 10mg order valsartan 160mg purchase diovan without prescription
cost amlodipine 5mg order cialis 20mg online cheap tadalafil price
lopressor drug purchase levitra without prescription levitra order
levitra generic vardenafil 20mg pills medrol buy
helpwithassignment write me a essay sildenafil 200mg for sale
brand clomiphene 100mg sports gambling legal online blackjack
order tadalafil 5mg buy plavix clopidogrel 150mg canada
buy generic losartan 50mg cheap nexium 20mg topiramate online buy
buy metronidazole 400mg for sale bactrim online order brand sulfamethoxazole
order keflex 500mg without prescription order cleocin 300mg generic buy erythromycin sale
online roulette real money order stromectol 6mg pills provigil without prescription
buy furosemide 40mg pills buy doxycycline without prescription hydroxychloroquine 400mg without prescription
naprosyn 250mg over the counter order naproxen 500mg without prescription prevacid 30mg tablet
spiriva 9mcg generic terazosin brand order generic hytrin
pioglitazone price order sildenafil 50mg pills buy viagra online
order cialis 5mg online play casino games for cash slot games online
real money slots free spins no deposit best casinos ladbrokes uk
purchase doxycycline doxycycline ca cleocin 300mg sale
diamox online buy imuran 50mg cost imuran online buy
buy digoxin 250mg online order lanoxin pill molnunat 200 mg generic
order generic alendronate 35mg nitrofurantoin 100mg price purchase motrin generic
order nortriptyline 25 mg order paracetamol 500 mg online paroxetine 10mg us
indocin 50mg ca order indomethacin 75mg pill purchase cenforce online
buy famotidine 40mg generic buy remeron 15mg for sale mirtazapine 15mg canada
requip 1mg tablet buy requip 1mg for sale order labetalol 100 mg pill
buy tadalafil without prescription tadalafil 10mg usa trimox 250mg brand
buy fenofibrate generic order tricor 200mg online cheap us pharmacy viagra
Everything is very open and very clear explanation of issues. was truly information. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
Thank you great posting about essential oil. Hello Administ . Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin
buy minocycline 100mg for sale order hytrin 5mg hytrin 5mg canada
Thank you for content. Area rugs and online home decor store. Hello Administ . Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin
order glycomet for sale tamoxifen tablet purchase nolvadex online cheap
cost modafinil 100mg provigil 200mg brand buy phenergan without prescription
buy clomiphene pill buy generic clomid 50mg prednisolone 5mg us
order sildenafil 50mg sale propecia 1mg uk buy finasteride 1mg for sale
can i buy ivermectin online stromectol 3mg sale buy prednisone online cheap
After all, what a great site and informative posts, I will upload inbound link – bookmark this web site? Regards, Reader.
buy ventolin generic buy ventolin inhalator generic buy generic augmentin 1000mg
buy modafinil 200mg purchase lopressor sale order lopressor pills
prednisolone oral order lasix generic buy furosemide diuretic
avodart 0.5mg uk buy avodart 0.5mg online cheap buy orlistat sale
buy imuran 25mg pills order imuran for sale naproxen 500mg usa
order cefdinir 300mg for sale cost cefdinir 300mg buy pantoprazole generic
order dapsone online cheap order mesalamine pill cheap atenolol 50mg
sildenafil medication sildenafil india order tadalafil online cheap
alfuzosin 10 mg drug buy alfuzosin 10 mg sale buy diltiazem 180mg without prescription
buy promethazine without prescription buy cialis without rx tadalafil otc
levaquin for sale where to buy levaquin without a prescription generic zyban 150 mg
zyrtec oral cetirizine 10mg over the counter sertraline over the counter
cenforce 100mg pill buy generic cenforce over the counter glycomet cheap
escitalopram 10mg price buy fluoxetine without prescription revia cheap
buy cialis pills oral cialis buy ed pills no prescription
ivermectin for people where can i buy accutane accutane for sale
order provigil 100mg buy deltasone 20mg for sale order deltasone for sale
clomid 50mg over the counter buy generic clomid for sale plaquenil 200mg brand
order metformin 1000mg buy atorvastatin 20mg online amlodipine 10mg without prescription
cheap biltricide hydrochlorothiazide online buy order cyproheptadine 4mg pills
order prinivil generic brand lisinopril 2.5mg buy lopressor online cheap
buy generic pregabalin 150mg buy pregabalin 150mg for sale priligy price
orlistat 120mg uk zyloprim 100mg brand allopurinol canada
oral cozaar topiramate 200mg oral order topamax 100mg online
order sumatriptan 25mg sale buy levofloxacin 250mg online how to buy dutasteride
ranitidine for sale order generic ranitidine 300mg order celecoxib 100mg pill
oral flomax oral tamsulosin 0.4mg brand spironolactone 100mg
buy cymbalta sale order glucotrol 5mg piracetam 800 mg canada
betnovate sale buy itraconazole 100 mg generic sporanox price
prometrium 200mg price order tindamax online zyprexa cheap
nateglinide 120 mg ca capoten 25 mg uk buy atacand pill
carbamazepine 200mg without prescription buy lincocin online buy lincocin 500mg generic
order estradiol pills estrace 2mg over the counter prazosin buy online
vermox brand tretinoin online buy tadalafil drug
cleocin 300mg price order cleocin 300mg sildenafil 100mg for sale
buy cheap generic tamoxifen cefuroxime 500mg over the counter order cefuroxime generic
trimox 500mg tablet order arimidex 1 mg pills biaxin 500mg cheap
buy clonidine without a prescription buy generic catapres over the counter where to buy tiotropium without a prescription
minocin 100mg cost minocycline 50mg tablet cheap pioglitazone 15mg
isotretinoin 40mg over the counter purchase isotretinoin pill zithromax over the counter
leflunomide drug sildenafil for men over 50 buy azulfidine 500mg without prescription
azithromycin 500mg oral buy generic omnacortil for sale gabapentin over the counter
cheap tadalafil tablets cialis 20 buy cialis online
buy generic lasix 100mg generic albuterol albuterol canada
buy generic levitra zanaflex brand plaquenil 200mg without prescription
Great post thank you. Hello Administ . Onwin , Onwin Giriş , Onwin Güncel Giriş , Tiklayin. Onwin
altace 5mg for sale altace medication buy etoricoxib no prescription
vardenafil oral order tizanidine pills buy hydroxychloroquine pills for sale
asacol 400mg price mesalamine 400mg pill avapro 150mg oral
purchase benicar without prescription calan 240mg for sale divalproex medication
diamox price oral azathioprine 25mg purchase azathioprine without prescription