exam questions

Exam 200-550 All Questions

View all questions & answers for the 200-550 exam

Exam 200-550 topic 1 question 51 discussion

Actual exam question from Zend's 200-550
Question #: 51
Topic #: 1
[All 200-550 Questions]

Consider the following table data and PHP code. What is the outcome?
Table data (table name "users" with primary key "id"):
id name email
------- ----------- -------------------
1 anna [email protected]
2 betty [email protected]
3 clara [email protected]
5 sue [email protected]
PHP code (assume the PDO connection is correctly established):
$dsn = 'mysql:host=localhost;dbname=exam';
$user = 'username';
$pass = '********';
$pdo = new PDO($dsn, $user, $pass);

try {
$cmd = "INSERT INTO users (id, name, email) VALUES (:id, :name, :email)";
$stmt = $pdo->prepare($cmd);
$stmt->bindValue('id', 1);
$stmt->bindValue('name', 'anna');
$stmt->bindValue('email', '[email protected]');
$stmt->execute();
echo "Success!";
} catch (PDOException $e) {
echo "Failure!";
throw $e;
}

  • A. The INSERT will succeed and the user will see the "Success!" message.
  • B. The INSERT will fail because of a primary key violation, and the user will see the "Success!" message.
  • C. The INSERT will fail because of a primary key violation, and the user will see a PDO warning message.
  • D. The INSERT will fail because of a primary key violation, and the user will see the "Failure!" message.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago