php连接mysql数据库
搞好php,就想把原来在java那部分学的东西往php上套下试试,没有建表,直接使用mysql自带的数据库表。代码如下
exec("set names 'utf8'"); $pdoStatement=$pdo->prepare($sql); $pdoStatement->execute((array($user))); $pdoStatement->bindColumn('host', $host); $pdoStatement->bindColumn('user', $user); $pdoStatement->bindColumn('password', $password); while ($row = $pdoStatement->fetch(PDO::FETCH_BOUND)) { echo $host; echo "
"; echo $user; echo "
"; echo $password; echo "
"; } } catch (PDOException $e) { print $e->getMessage(); } echo "end";