那么最原始的php是怎么连接mysql的呢,请看下文
lost主机名
peter 数据库名称
abc123 数据库密码
用mysql_connect函数。连接失败会返回false 根据这个判断是否连接上数据库
mysql_error()用于描述是什么错误,密码错误啊等方便查找问题
<?php
$con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } // some code ?>