<?php $mysqli=@new mysqli("localhost", "root", "123456", "xsphpdb"); if(mysqli_connect_errno()){ echo "连接数据库失败:".mysqli_connect_error(); $mysqli=null; exit; } //select语句(结果集), 非select语句,会影响行数 $sql="insert into shops(name,price,num,desn) values('hello','34.56','22','good123')"; $result=$mysqli->query($sql); if(!$result){ echo "SQL语句有误<br>"; echo "ERROR:".$mysqli->errno."|".$mysqli->error; exit; } echo $mysqli->affected_rows; $mysqli->close();