{"id":294,"date":"2014-06-30T14:44:30","date_gmt":"2014-06-30T14:44:30","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=294"},"modified":"2014-06-30T14:44:30","modified_gmt":"2014-06-30T14:44:30","slug":"php%e8%bf%9e%e6%8e%a5mysql%e7%9a%84%e8%84%9a%e6%9c%ac%e7%89%87%e6%ae%b5","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/294.html","title":{"rendered":"PHP\u8fde\u63a5MySQL\u7684\u811a\u672c\u7247\u6bb5"},"content":{"rendered":"<h6>\u8bb0\u5f55\u5907\u7528\uff1a<\/h6>\n<pre class=\"lang:php decode:true\">&lt;?php\n$con = mysql_connect(\"localhost\", \"root\", \"your_passwd\");\nif (!$con) {\n\tdie(\"Could not connect: \" . mysql_error());\n}\n$db_selected = mysql_select_db(\"db_name\", $con);\nif (!$db_selected) {\n\tdie (\"Can't use db_name: \" . mysql_error());\n}\n\nfunction mquery($query, $conn, $exit=true) {\n\t$data = @mysql_query($query, $conn);\n\tif($data === false &amp;&amp; $exit) {\n\t\texit(\"mquery error:\" . mysql_error());\n\t}\n\treturn $data;\n}\nfunction getData($query, $conn) {\n\t$output = array();\n\t$result = mquery($query, $conn);\n    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {\n        $output[] = $row;\n    }\n\treturn $output;\n}\n?&gt;<\/pre>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bb0\u5f55\u5907\u7528\uff1a &lt;?php $con = mysql_connect(&#8220;localhost&#8221;, &#8220;root&#8221; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,7,12],"tags":[16,48],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-database","category-programing","category-tools","tag-mysql","tag-php"],"views":2129,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=294"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/294\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}