{"id":1254,"date":"2017-12-21T22:51:25","date_gmt":"2017-12-21T13:51:25","guid":{"rendered":"https:\/\/coeure.co.jp\/blog\/?p=1254"},"modified":"2026-04-03T15:40:56","modified_gmt":"2026-04-03T06:40:56","slug":"mysql_error_171221","status":"publish","type":"post","link":"https:\/\/coeure.co.jp\/blog\/programing\/mysql_error_171221","title":{"rendered":"\u3010MySQL+PHP\u3011MySQL\u304b\u3089\u53d6\u5f97\u3057\u305f\u65e5\u672c\u8a9e\u30c7\u30fc\u30bf\u306e\u6587\u5b57\u5316\u3051 \uff0d \u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u5f53\u793e\u306f\u3001PHP+MySQL\u306e\u52e4\u6020\u30b7\u30b9\u30c6\u30e0\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u30ec\u30f3\u30bf\u30eb\u30b5\u30fc\u30d0\u5f15\u3063\u8d8a\u3057\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u52e4\u6020\u30b7\u30b9\u30c6\u30e0\u3082\u79fb\u884c\u3059\u308b\u5fc5\u8981\u304c\u751f\u3058\u307e\u3057\u305f\u3002PHP\u30b9\u30af\u30ea\u30d7\u30c8\u3068MySQL\u306e\u30c7\u30fc\u30bf\u79fb\u884c\u304c\u7d42\u308f\u308a\u3001\u30ed\u30b0\u30a4\u30f3\u753b\u9762\u304b\u3089\u30ed\u30b0\u30a4\u30f3\u3082\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u5168\u89d2\u6587\u5b57\u306e\u4e00\u90e8\u304c\u6587\u5b57\u5316\u3051\u3059\u308b\u3068\u3044\u3046\u554f\u984c\u304c\u751f\u3058\u307e\u3057\u305f\u3002\u8abf\u67fb\u3057\u3066\u7121\u4e8b\u89e3\u6c7a\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">\u767a\u751f\u3057\u305f\u554f\u984c<\/h2>\n\n\n\n<p>\u4eca\u56de\u3001\u6587\u5b57\u5316\u3051\u3057\u305f\u306e\u306f\u3001\u4e00\u90e8\u306e\u5168\u89d2\u6587\u5b57\u3067\u3057\u305f\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u8868\u306e\u30d8\u30c3\u30c0\u30fc\u306a\u3069PHP\u5185\u304b\u3089\u76f4\u63a5\u51fa\u529b\u3057\u3066\u3044\u308b\u6587\u5b57\u5217\u306b\u3064\u3044\u3066\u306f\u3001\u5168\u89d2\u6587\u5b57\u3067\u3082\u6b63\u3057\u304f\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u4e00\u65b9\u3001MySQL\u304b\u3089\u53d6\u5f97\u3057\u305f\u5168\u89d2\u6587\u5b57\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u3066\u3044\u308b\u7b87\u6240\u306f\u3001\u3053\u3068\u3054\u3068\u304f\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u554f\u984c\u306f\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u306e\u8a2d\u5b9a\u306b\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>MySQL\u5185\u306f\u3001UTF-8\u3067\u30c7\u30fc\u30bf\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u307e\u3059\u3002PHP\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3082UTF-8\u3067\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306b\u3001PHP\u5185\u90e8\u3067\u306f\u3069\u306e\u3088\u3046\u306a\u6587\u5b57\u30b3\u30fc\u30c9\u3067\u51e6\u7406\u3055\u308c\u3066\u3044\u308b\u306e\u304b php.ini \u3067\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002mbstring.internal_encoding \u3068\u3044\u3046\u9805\u76ee\u3092\u898b\u3066\u307f\u307e\u3059\u3068\u300cno value\u300d\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3069\u3046\u3084\u3089PHP\u5185\u90e8\u3067\u306f\u3001UTF-8\u3068\u3057\u3066\u8a8d\u8b58\u3057\u3066\u51e6\u7406\u304c\u3067\u304d\u3066\u3044\u306a\u3044\u3053\u3068\u304c\u539f\u56e0\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u3001\u4ee5\u524d\u306b\u4f7f\u3063\u3066\u3044\u305f\u30ec\u30f3\u30bf\u30eb\u30b5\u30fc\u30d0\u306e php.ini \u3092\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001mbstring.internal_encoding \u306b\u306f UTF-8 \u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002\u305d\u306e\u305f\u3081\u3001\u6587\u5b57\u5316\u3051\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n\n\n\n\n\n\n\n\n<h2 class=\"wp-block-heading\">\u6587\u5b57\u5316\u3051\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h2>\n\n\n\n<p>\u3055\u3066\u3001\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306b\u306f mysqli_set_charset() \u3068\u3044\u3046\u95a2\u6570\u3092\u7528\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3057\u304b\u3057\u3001\u52e4\u6020\u30b7\u30b9\u30c6\u30e0\u304c\u5c11\u3005\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3042\u308bPHP5.3\u3067\u52d5\u3044\u3066\u3044\u308b\u305f\u3081\u3001mysql_set_charset() \u3068\u3044\u3046\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002PHP\u30de\u30cb\u30e5\u30a2\u30eb\u306b\u3088\u308b\u3068\u3053\u306e\u95a2\u6570\u306f\u3001PHP5.5.0\u3067\u975e\u63a8\u5968\u306b\u306a\u308a\u3001PHP7.0.0\u3067\u524a\u9664\u3055\u308c\u3066\u3057\u307e\u3063\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067 \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u8a00\u3046\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3068\u3044\u3046\u306e\u306fPHP\u5074\u306e\u3053\u3068\u3067\u3001\u30b5\u30fc\u30d0\u5074\u3068\u3044\u3046\u306e\u306fMySQL\u5074\u3092\u6307\u3057\u3066\u3044\u308b\u3068\u601d\u308f\u308c\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u30b5\u30fc\u30d0\u5074\u3068\u304b\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u3068\u304b\u8a00\u3063\u3066\u3082\u3001\u30ec\u30f3\u30bf\u30eb\u30b5\u30fc\u30d0\u306e\u5834\u5408\u306f\u3001\u540c\u4e00\u30b5\u30fc\u30d0\u5185\u306b\u540c\u5c45\u3057\u3066\u3044\u308b\u3068\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u3082\u3042\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u3055\u3066\u3001PHP\u30b9\u30af\u30ea\u30d7\u30c8\u5185\u3067MySQL \u306b\u63a5\u7d9a\u5f8c\u3001 mysql_set_charset() \u95a2\u6570\u3092\u4f7f\u3063\u3066\u6587\u5b57\u30b3\u30fc\u30c9\u3092 UTF-8 \u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u6587\u5b57\u5316\u3051\u3092\u56de\u907f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>mysql_set_charset(&#39;utf8&#39;);<\/code><\/pre><\/div>\n\n\n\n<p>\u3061\u306a\u307f\u306b\u3001\u4ee5\u4e0b\u306e\u4e00\u6587\u3092\u5165\u308c\u308b\u3053\u3068\u3067\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u3068\u3044\u3046\u65b9\u6cd5\u3082\u3042\u3063\u305f\u3088\u3046\u3067\u3059\u3002\u3057\u304b\u3057\u3001PHP\u30de\u30cb\u30e5\u30a2\u30eb\u3068\u898b\u3066\u307f\u307e\u3059\u3068\u3001mysql_set_charset() \u3092\u4f7f\u3046\u3053\u3068\u304c\u63a8\u5968\u3055\u308c\u3066\u304a\u308a\u3001mysql_query() \u3092\u4f7f\u3063\u3066\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u306f\u52e7\u3081\u3089\u308c\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>mysql_query(&#39;SET NAMES utf8&#39;);<\/code><\/pre><\/div>\n\n\n\n\n\n\n\n\n\n\n\n<p>\u4eca\u56de\u306e\u554f\u984c\u306f\u3001mysql_set_charset() \u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u6587\u5b57\u30bb\u30c3\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u89e3\u6c7a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u3057\u304b\u3057\u3001mysql_set_charset()\u95a2\u6570\u306f\u3001\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u306ePHP\u3067\u306f\u524a\u9664\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u8003\u3048\u308b\u3068\u65e9\u6025\u306bmysqli_set_charset()\u95a2\u6570\u3078\u306e\u7f6e\u304d\u63db\u3048\u3092\u5b9f\u65bd\u3057\u306a\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3067\u306f\u3001\u4eca\u56de\u306f\u3053\u3053\u307e\u3067\u3067\u3059\u3002<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u793e\u306f\u3001PHP+MySQL\u306e\u52e4\u6020\u30b7\u30b9\u30c6\u30e0\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u30ec\u30f3\u30bf\u30eb\u30b5\u30fc\u30d0\u5f15\u3063\u8d8a\u3057\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u52e4\u6020\u30b7\u30b9\u30c6\u30e0\u3082\u79fb\u884c\u3059\u308b\u5fc5\u8981\u304c\u751f\u3058\u307e\u3057\u305f\u3002PHP\u30b9\u30af\u30ea\u30d7\u30c8\u3068MySQL\u306e\u30c7\u30fc\u30bf\u79fb\u884c\u304c\u7d42\u308f\u308a\u3001\u30ed\u30b0\u30a4\u30f3\u753b\u9762\u304b\u3089\u30ed\u30b0\u30a4\u30f3\u3082\u3067\u304d\u308b\u3088\u3046\u306b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1297,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[10],"tags":[],"class_list":["post-1254","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programing"],"_links":{"self":[{"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/posts\/1254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=1254"}],"version-history":[{"count":10,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/posts\/1254\/revisions"}],"predecessor-version":[{"id":6508,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/posts\/1254\/revisions\/6508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/media\/1297"}],"wp:attachment":[{"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=1254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=1254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coeure.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=1254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}