! PHP PDO连接mysql失败

WBOY
Release: 2016-06-13 12:20:40
Original
1302 people have browsed it

求助!! PHP PDO连接mysql失败
在conn.php中用pdo连接本地的mysql数据库, 但php网页提交的数据在mysql里面没有存入, 但是运行conn.php不报错, 不知道到底是哪里有问题!! 纠结了三天了!!拜托各位看看

<?php<br />try {<br />  $dns = 'mysql:host=localhost;dbname=satcliv8;port=3306';<br />  $utilisateur = 'root';<br />  $motDePasse = '';<br />  $connection = new PDO( $dns, $utilisateur, $motDePasse ,<br />      array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));<br /><br />} catch ( Exception $e ) {<br />  echo "Connection ?? MySQL impossible : ", $e->getMessage();<br />  die();<br />}<br />?>
Copy after login

------解决思路----------------------
你这只是连接
你是怎么用的呢?
------解决思路----------------------
http://www.w3cschool.cc/php/pdo-errorinfo.html
用这可以检查mysql error,试试看吧
------解决思路----------------------
看看错误日志。
------解决思路----------------------
host unknown也就是找不到host,你是怎么连接的?ip还是域名。
贴一下。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!