原生 原始 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

 

posted @ 2016-10-12 13:52  WilliamShaw  阅读(4677)  评论(0编辑  收藏  举报