原生 原始 PHP连接MySQL 代码 参考mysqli pdo
1、mysql
header("Content-Type: text/html; charset=utf-8") ; set_time_limit(0); error_reporting( E_ALL&~E_NOTICE ); $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test2", $con); $result = mysql_query("SELECT * FROM ad"); while($row = mysql_fetch_array($result)) { echo $row['title'] . " " . $row['url']; echo "<br />"; } mysql_close($con);
2、mysqli