MySQLi - Warning Count
语法
int mysqli_warning_count ( mysqli $link )
定义和用法
它返回给定链接的最后一次查询的警告数量
示例
尝试以下示例 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if (!$conn->real_connect($servername, $username, $password, $dbname)) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); } echo "Database connected"; mysqli_query($conn, "CREATE TABLE send18 LIKE tutorials_auto"); $query = "INSERT INTO myCity (id,name) VALUES( 1,'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')"; mysqli_query($conn, $query); if (mysqli_warning_count($conn)) { if ($result = mysqli_query($conn, "SHOW WARNINGS")) { $row = mysqli_fetch_row($result); printf("%s (%d): %s ", $row[0], $row[1], $row[2]); mysqli_free_result($result); } } mysqli_close($conn); ?>