ec(2); php 入门篇-如何判断mysql数据库连接成功 $cn = mysql_connect('localhost','root','root'); if( $cn ) { die('数据库连接成功'); } else { die('连接失败'); } ?>