100+ câu trắc nghiệm Các kỹ thuật thiết kế Web có đáp án - Phần 1

Xem đoạn mã sau:phpĐoạn mã trên thực hiện lệnh gì?

6/25

Xem đoạn mã sau:

"

$con = mysql_connect("localhost","peter","abc123");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons");

while($row = mysql_fetch_array($result))

{

echo $row['FirstName'] . " " . $row['LastName'];

echo "

";

}

mysql_close($con);

?>

Đoạn mã trên thực hiện lệnh gì?

Kết nối dữ liệu đến máy hiện tại (localhost) với username là "peter" password là "abc123" và in dữ liệu từ bảng Persons ra trình duyệt

Kết nối dữ liệu đến máy khách với username là "peter" password là "abc123" và in dữ liệu từ bảng Persons ra trình duyệt

Kết nối dữ liệu đến máy hiện tại (localhost) với username là "abcd123" password là "peter" và in dữ liệu từ bảng Persons ra trình duyệt

Kết nối dữ liệu đến máy hiện tại (localhost) với username là "peter" password là "abc123" và xóa dữ liệu từ bảng Persons

Giải thích

Chọn đáp án A