Rumah >pembangunan bahagian belakang >tutorial php >php pdo 连接MySQL数据库
<code><span><span><?php </span><span>$dbhost</span> =<span>"localhost"</span>; <span>$dbuser</span> = <span>"root"</span>; <span>$dbpwd</span> = <span>"123"</span>; <span>$dbname</span> = <span>"mydatabase"</span>; <span>$charName</span> = <span>"utf8"</span>; <span>try</span> { <span>$conn</span> = <span>new</span> PDO(<span>"mysql:host=$dbhost;port=3306;dbname=$dbname"</span>, <span>$dbuser</span>, <span>$dbpwd</span>, <span>array</span>(PDO::MYSQL_ATTR_INIT_COMMAND => <span>"set names utf8"</span>)); <span>//echo "数据库链接成功!"; </span> } <span>catch</span>(PDOException <span>$e</span>){ <span>echo</span><span>$e</span>->getMessage(); } <span>?></span></span></span></code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了php pdo 连接MySQL数据库,包括了Mysql数据库,连接MySql方面的内容,希望对PHP教程有兴趣的朋友有所帮助。