my_personal_contacts
my_person_contacts
TẠO BẢNG NẾU KHÔNG TỒN TẠI `my_contacts` [
`id` int[11] KHÔNG NULL AUTO_INCREMENT,
`full_names` varchar[255] KHÔNG NULL,
`giới tính` varchar[6] KHÔNG NULL,
`contact_no` varchar[75] KHÔNG NULL,
`email` varchar[255] KHÔNG NULL,
`city` varchar[255] KHÔNG NULL,
`quốc gia` varchar[255] KHÔNG NULL,
] ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT = 5 ;
CHÈN VÀO `my_contacts` [
[1, 'Zeus', 'Nam', '111', 'zeus@olympus. tấn. co', 'Agos', 'Hy Lạp'],
[2, 'Athena', 'Nữ', '123', 'athena@olympus. tấn. co', 'Athens', 'Hy Lạp'],
[3, 'Jupiter', 'Nam', '783', 'jupiter@planet. điểm. co', 'Rome', 'Ý'],
[4, 'Venus', 'Female', '987', 'venu @planet. điểm. co', 'Mars', 'Ý'];
$mysqli = new mysqli["localhost", "my_user", "my_password", "world"];
/* check connection */
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* Create table doesn't return a resultset */
if [$mysqli->query["CREATE TEMPORARY TABLE myCity LIKE City"] === TRUE] {
printf["Table myCity successfully created.\n"];
}
/* Select queries return a resultset */
if [$result = $mysqli->query["SELECT Name FROM City LIMIT 10"]] {
printf["Select returned %d rows.\n", $result->num_rows];
/* free result set */
$result->close[];
}
/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
if [$result = $mysqli->query["SELECT * FROM City", MYSQLI_USE_RESULT]] {
/* Note, that we can't execute any functions which interact with the
server until result set was closed. All calls will return an
'out of sync' error */
if [!$mysqli->query["SET @a:='this will not work'"]] {
printf["Error: %s\n", $mysqli->error];
}
$result->close[];
}
________số 8_______
$link = mysqli_connect["localhost", "my_user", "my_password", "world"];
/* check connection */
if [mysqli_connect_errno[]] {
printf["Connect failed: %s\n", mysqli_connect_error[]];
exit[];
}
/* check connection */
0
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
1
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
2
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
3
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
4
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
5
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
Trả về FALSE khi thất bại. Đối với các truy vấn CHỌN, HIỂN THỊ, MÔ TẢ hoặc GIẢI THÍCH thành công, mysqli_query[] sẽ trả về một đối tượng mysqli_result. Đối với các truy vấn thành công khác, mysqli_query[] sẽ trả về TRUE
Định hướng của đối tượng
$mysqli = new mysqli["localhost", "my_user", "my_password", "world"];
/* check connection */
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* Create table doesn't return a resultset */
if [$mysqli->query["CREATE TEMPORARY TABLE myCity LIKE City"] === TRUE] {
printf["Table myCity successfully created.\n"];
}
/* Select queries return a resultset */
if [$result = $mysqli->query["SELECT Name FROM City LIMIT 10"]] {
printf["Select returned %d rows.\n", $result->num_rows];
/* free result set */
$result->close[];
}
/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */
if [$result = $mysqli->query["SELECT * FROM City", MYSQLI_USE_RESULT]] {
/* Note, that we can't execute any functions which interact with the
server until result set was closed. All calls will return an
'out of sync' error */
if [!$mysqli->query["SET @a:='this will not work'"]] {
printf["Error: %s\n", $mysqli->error];
}
$result->close[];
}
________số 8_______
$link = mysqli_connect["localhost", "my_user", "my_password", "world"];
/* check connection */
if [mysqli_connect_errno[]] {
printf["Connect failed: %s\n", mysqli_connect_error[]];
exit[];
}
/* check connection */
0
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
1
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
2
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
3
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
4
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}
/* check connection */
5
if [$mysqli->connect_errno] {
printf["Connect failed: %s\n", $mysqli->connect_error];
exit[];
}