


心血来潮,看着教程写了一个php连接mysql的代码,比较简单,适合初学者,高手跳过
- <?php
- $host='127.0.0.1';
- $user='root';
- $passwd='123456ab';
- $conn=mysql_connect($host,$user,$passwd);
- if (!$conn) {
- die("数据库连接失败".mysql_error()); }
- else{
- echo "<br>地址:$host <br> 用户名:$user <br> 密码:$passwd ";
- echo "<br>数据库连接成功,恭喜";
- }
- ?>
请根据自己需要修改。
运行后如图



亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论