php5.3以上版本不建议使用mysql_connect ,mysql_query等函数,转而使用mysqli系列(improved)。这是连接数据库及查询数据的两个例子。
<?php
require 'conn.php'; //$link=mysqli_connect($host,$user,$pass,$database);
$query="select * from user_info";
if($result=mysqli_query($link,$query)){
echo "query was successfully executed.".'<br>';
while($row=mysqli_fetch_assoc($result)){
echo $row["name"]." ".$row["surname"].'<br>';
}
mysqli_free_result($result);
}
else{
echo "the query is not executed.".'<br>';
}
mysqli_close($link);
?>
<?php
/**
* Created by PhpStorm.
* User: KPF
* Date: 2016/6/28
* Time: 17:21
*/
require_once('json.php');