<?php
$link = mysqli_connect('localhost', 'root', '', 'test')
or die('Connect Error: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error());
print_r($link);
<?php
$link = mysqli_connect('localhost', 'root', '', 'test')
or die('Connect Error: ' . mysqli_connect_errno() . ': ' . mysqli_connect_error());
mysqli_set_charset($link, 'UTF8');
$sql = "INSERT user(username,password,age) VALUES('imooc1','imooc1',22);";
$res = mysqli_query($link, $sql);
if ($res) {
echo "AUTO_INCREMENT:" . mysqli_insert_id($link);
echo "<hr/>";
echo 'AFFECTED ROWS ' . mysqli_affected_rows($link);
} else {
echo mysqli_errno($link) . ":" . mysqli_error($link);
}
?>