php向数据库插入数据乱码问题
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> book entry result <h1 id="book-entry-result">book entry result</h1> <?php header("content-type:text/html;charset=utf-8"); $isbn=$_POST['isbn']; $author=$_POST['author']; $title=$_POST['title']; $price=$_POST['price']; if(!($isbn||$author||$title||$price)) { echo"请确认每行都输入数据"; exit; } if(!get_magic_quotes_gpc()) { $isbn=addslashes($isbn); $author=addslashes($author); $title=addslashes($title); $price=addslashes($price); } mysql_query('set names utf8'); @$db=new mysqli('localhost','root','root','books'); if(mysqli_connect_error()) { echo "链接数据库不成功"; exit; } header("content-type:text/html;charset=utf-8"); $query="insert into books(isbn ,author ,title ,price) values('".$isbn."', '".$author."', '".$title."', '".$price."')"; $result=$db->query($query); if($result){ echo $db->affected_rows." 本书数据录入成功。"; }else{ echo"数据录入失败。"; } ?>
我已经用header()把php页变成utf-8
数据库和表的的编码都是utf-8
------解决方案--------------------
------解决方案--------------------
我以前遇到过程序编码正常,页面显示正常,唯独phpmyadmin中乱码的情况。那是phpmyadmin的配置没弄好,不过我也不知道怎么改。你可以写个简单的小程序把数据库内容读到页面显示看看
------解决方案--------------------
程序编码是不是有问题的。
------解决方案--------------------
应该先执行mysql_connnet(……),链接好数据库在执行mysql_query("set names utf-8");吧

Fujifilm fans were recently very excited at the prospect of the X-T50, since it presented a relaunch of the budget-oriented Fujifilm X-T30 II that had become quite popular in the sub-$1,000 APS-C category. Unfortunately, as the Fujifilm X-T50's launc

TheFiiOCP13cassetteplayerwasannouncedinJanuary.Now,FiiOisexpandingitsportfoliowithtwonewmodels-onewitharedfrontandonewithatransparentfront.Thelatternotonlyperfectlymatchestheretrocharmoftheangulardesign,butalso

The Klipsch Flexus Core 300 is the top model in the series and is positioned above the already available Flexus Core 200 in the company's soundbar line-up. According to Klipsch, this is the first soundbar in the world whose sound can be adapted to th

WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

在这篇文章中,我们将向你展示如何通过拖放在PowerQuery中对多列进行重新排序。通常,从各种来源导入数据时,列可能不是所需的顺序。重新排序列不仅允许您按照符合您的分析或报告需求的逻辑顺序排列它们,还可以提高数据的可读性,并加快过滤、排序和执行计算等任务。如何在Excel中重新排列多个列?在Excel中,重新排列列的方法有多种。您可以简单地选择列标题,然后将其拖动到所需位置。但是,当处理包含许多列的大表时,这种方法可能会变得繁琐。为了更高效地重新排列列,您可以使用增强查询编辑器。通过增强查询编

ReactQuery数据库插件:实现数据导入和导出的方法,需要具体代码示例随着ReactQuery在前端开发中的广泛应用,越来越多的开发者开始使用它来管理数据。而在实际开发中,我们经常需要将数据导出到本地文件或从本地文件导入数据到数据库中。为了更方便地实现这些功能,可以使用ReactQuery数据库插件。ReactQuery数据库插件提供了一系列方

title是定义网页标题的意思,位于标签内,并且是在浏览器的标题栏中显示的文本,title对于网页的搜索引擎优化和用户体验都非常重要。在编写HTML网页时,应该注意使用相关的关键词和吸引人的描述来定义title元素,以便吸引更多的用户点击和浏览。

Shortly after Tesla launched the Model 3 Highland refresh towards the end of last year, the US federal EV tax incentive rules changed, cutting the potential discount in half for eligible buyers because of Tesla's use of Chinese LFP cells in the new M


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구
