9.3 Activities, 9.2 Activities, 9.1 Activities, 8.8 Activities, 8.7 Activities, 8.6 Activities, 8.5 Activities, 8.4 Acrtivities, 8.2 Activities, 8.1 Activities, 7.9 Quizlet, 7.8 Activities, 7.7 Activities, 7.6 Activities, 7.5 Activities, 7.4 Activiti...

Ace your homework & exams now with Quizwiz!

What is the SQL statement for the CRUD operation (2 word) Update

ALTER TABLE

Look at table on 8.4.12 What does this statement do? UPDATE shows SET title = 'The Office' WHERE seasons = 9;

All shows are assigned the title "The Office" and season set to 9

LIKE '%row'

Arrow

What is the last name output by the for loop? $names = ["Beth", "Lance", "Jose"]; for ($i = count($names) - 1; $i >= 0; $i--) { echo $names[$i], "\n"; }

Beth

What is the SQL statement for the CRUD operation (2 word) Create

CREATE TABLE

What is the data type for the column last_name

Character

LIKE '%c_m%'

Community

What is the SQL statement for the CRUD operation (1 word) Delete

DELETE

What is the SQL statement for the CRUD operation (2 word) Delete

DROP TABLE

INSERT INTO students VALUES ('Ebony', 555, 3.9);

Data is not in the correct order

What is the data type for the column hire_date

Date

What is the PHP error code for.. while (TRUE);

E_ERROR - fatal error (a while loop that never terminates causes the script to execute too long)

What is the PHP error code for.. echo $uninitializedVariable;

E_NOTICE - notice (outputting an uninitialized variable generates a notice)

What is the PHP error code for.. echo $answer

E_PARSE - parse error (a missing semicolon at the end of a statement causes a parse error)

What is the PHP error code for.. $answer = 2/0;

E_WARNING - warning (division by zero causes a warning)

$quote = "Every man dies. Not every man lives."; preg_replace("/\d+/", "one", $quote);

Every man dies. Not every man lives.

$quote = "Every man dies. Not every man lives."; preg_replace("/man/", "one", $quote);

Every one dies. Not every one lives.

Look at table in 8.6.2 What data does this SELECT statement select SELECT * FROM tv_show;

Everything in the table

$quote = "Every man dies. Not every man lives."; preg_replace("/[aeiou]/", "", $quote);

Evry mn ds. Nt vry mn lvs.

"123" === 123

False

True or False "bat" < "ball"

False

True or False An INSERT statement must name the table's columns

False

True or False? The row with values 123, 1004, C can be added to the enroll table.

False

True or False? The student table has a column for storing student addresses.

False

True or False? The students table may contain two students with the same stuId.

False

True or False? SQL syntax from one RDBMS usually works without modification in another RDBMS

False (Each RDBMS customizes SQL to some degree, so SQL syntax often needs updating when moving from one RDBMS to another)

True or False? The words "CREATE TABLE" must be capitalized in a CREATE TABLE statement.

False (SQLs are not case sensitive; common practice is to uppercase though)

True or False? Client-side data validation makes server-side data validation unnecessary.

False (Server-side data validation is always necessary because client-side data validation can be circumvented)`

True or False? The if statement is true. if (ord("Hello") < ord("Goodbye")) { ... }

False (The ASCII value of "H" is 72, and the ASCII value of "G" is 71. 72 is not less than 71, so the if statement is false.)

The following code uses the getData() function from the figure above and provides sufficient data validation for a 16 digit credit card number. $creditCardNum = getData("creditCardNum"); if (strlen($creditCardNum) == 16) { // Valid number } else { // Invalid number }

False (The code does not ensure that $creditCardNum contains only digits, and $creditCardNum could contain spaces between the numbers, so the length could be longer than 16 characters. A regular expression (discussed elsewhere) is ideal for checking text against an expected pattern.)

True or False? When an HTML form uses method="post" and submits to a PHP script, the form values appear in the URL's query string

False (The form data is sent to the PHP script in the HTTP request body)

The regex /run/ matches the string "pr uning".

False (The space between "r" and "un" causes the regex not to match)

Referring to the figures above, if the user submitted the name as "<h1>Pam</h1>" and howmany as 4 , the browser would display: "Pam ordered 4 widgets."

False (htmlspecialchars() converts < into &lt; and > into &gt;, so the echo statement outputs "<p>&lt;h1&gt;Pam&lt;/h1&gt; ordered 4 widgets.</p>". The browser displays &lt; and &gt; as < and >, so the browser displays "<h1>Pam</h1> ordered 4 widgets.")

True or False PHP code runs in a web browser

False PHP code runs on a web server

True or False? Only PHP files may be included with the include statement.

False (Any textual file may be included)

Refer to table on 9.1.1 True or False? The UPDATE statement changes Miller's GPA to 3.0. UPDATE student SET gpa = 3.0 WHERE stu_id = 987;

False (Millers stuID is 123)

True or False The following INSERT statements add two students into the students table. INSERT INTO student VALUES (777, 'Red', 'Rosy', 4.0); INSERT INTO student VALUES (777, 'White', 'Willow', 3.1);

False (Rosy and Willow share the same student id, so there is only one)

True or False? The include statement inserts the contents of another file before the PHP script executes.

False (The included file is inserted as the PHP script executes)

Refer to figure 8.8.5 True or False? If $stuid is not in the students table, a PDOException is thrown.

False (execute() only throws a PDOException if the UPDATE statement is invalid. If $stuid is not in the students table, rowCount() returns 0.)

True or False? In the animation above, footer.php used a variable defined in header.php. header.php could also have used a variable defined in footer.php

False (footer.php is included after header.php, so when header.php is executed, footer.php has not been included. So, a variable defined in footer.php is undefined when header.php executes)

True or False? The number 5 billion may be stored in an INTEGER column.

False (largest integer value is 2 million)

Refer to table on 9.1.1 True or False? The UPDATE statement changes Lopez's student ID and GPA. UPDATE student SET stu_id = 123, gpa = 2.5 WHERE stu_id = 456;

False (stu_ID 123 is already set to Miller)

True or False? Web applications typically use the same physical database in both the development environment and deployment environment

False (typically the same database is duplicated in both environments)

LIKE BINARY '%A%'

Greys Anatomy and Arrow

Look at table in 8.6.6 What show titles does the LIKE statement grab? LIKE '%an%'

Greys Anatomy and Parks and Recreation

Enter the value assigned to $x in each code segment. $quote = "I am Spartacus!"; $x = str_replace("am", "was", $quote);

I was Spartacus! (str_replace() replaces "am" with "was" in the quote and returns the new string)

What value is $points? $points = 4; $points /= 0;

INF (undefined)

What is the SQL statement for the CRUD operation (1 word) Create

INSERT

INSERT INTO students VALUES (777, 'O'Malley', 3.0);

Illegal use of single quotation mark (have to say 'O/'Malley')

INSERT INTO students VALUES 222, 'Darnell'. 3.0;

Missing parenthesis around data values

What is the syntax error for this statement? INSERT INTO students VALUES (444, Zack, 3.2);

Missing single quotation marks

Must every primary key value be used in a foreign key? Yes or No?

No

Can two classes with the same course_id have a different number of credit hours? Yes or No?

No (When both classes have the same course_id, both classes share all the same values from the course table)

LIKE '_row'

No matches

Look at table on 8.4.12 What does this statement do? UPDATE shows SET title = 'The Office' WHERE showId = 999;

No shows are updated

What is the data type for the column fac_id

Number

business logic

Programming logic on the front or back-end that determines how data can be created, displayed, stored, and changed.

Enter the command to exit the mysql tool.

QUIT

data modeling

Representing, storing, and retrieving application data in relational and non-relational databases.

Complete the SQL statement to display all the songs in the songs table. ____ * from songs;

SELECT

What is the SQL statement for the CRUD operation (1 word) Retrieve

SELECT

How would you change this to only select movies released after October 31st, 2015 SELECT * FROM movie;

SELECT * FROM movie WHERE release_date > '2015-10-31';

Look at table on 8.4.12 What does this statement do? DELETE FROM shows WHERE MONTH(releaseDate) = 7;

Seinfeld is removed from the table

NOT LIKE '%o%'

The Blacklist

Look at table on 8.4.12 What does this statement do? DELETE FROM shows WHERE title LIKE '%Files';

The X-Files is removed from the table

Look at table on 8.4.12 What does this statement do? UPDATE shows SET title = 'The Office' WHERE seasons > 6;

The X-files and Seinfeld are assigned the title "The Office"

Enter the value assigned to $x in each code segment. $quote = "I am Spartacus!"; $x = "This is " . substr($quote, 5, 6) . "!";

This is Sparta! (substr() returns "Sparta", which begins at index 5 and is 6 characters long. "This is " . "Sparta" . "!" = "This is Sparta!")

What value is $message? $message = "Top"; $message .= "secret";

Topsecret ("Top" . "secret" = "Topsecret".)

"123" == 123

True

("10" <=> "010") == 0

True

("bat" <=> "ball") > 0

True

2 > 10 || (3 % 2 != 2 && 5 > 0)

True

Refer to figure 8.8.5 True or False? rowCount() returns 0 if the executed DELETE statement does not delete any rows.

True

Refer to figure 8.8.5 True or False? rowCount() returns the number of rows selected by a SELECT statement.

True

Refer to table on 9.1.1 True or False? The UPDATE statement changes Nguyen's student ID and GPA. UPDATE student SET stu_id = 444, gpa = 2.5 WHERE last_name = 'Nguyen';

True

True or False The following INSERT statements add two students into the students table. INSERT INTO student VALUES (999, 'Black', 'Bill', 3.9); INSERT INTO student VALUES (888, 'Green', 'Gary', 3.1);

True

True or False Many PHP applications run on Linux with an Apache web server and MySQL as the database

True

True or False PHP is used by Facebook, Wikipedia, and WordPress

True

True or False? Each MySQL user is assigned a username and password.

True

True or False? MySQL is a popular choice for web hosting companies that provide an RDBMS for their customers.

True

True or False? The mysql tool attempts to connect to MySQL server running on the same machine as the tool.

True

True or False? A table typically has at least one column that uniquely identifies each row.

True

True or False? An RDBMS may be commercial or open-source software

True

True or False? Every class has at least one enrolled student.

True

True or False? Only one student has less than a 3.0 GPA.

True

True or False? The University database has three tables

True

True or False? The class that meets in room SCI 200 has 2 enrolled students.

True

True or False? The students table may contain two students with the same name.

True

True or Flase? Most RDBMSs use SQL as the system's query language

True

True or False? When an HTML form uses method="get" and submits to a PHP script, $_GET will contain all the values entered in the form

True (The form data is sent to the PHP script in the query string)

True or False? If a form submits data with method="get" then $_POST will be empty.

True (The form must use method="post" for $_POST to contain values)

True or False? $name is set to "SPIDER-MAN". $name = strtoupper("Spider-Man");

True (strtoupper() converts the entire string to uppercase)

True False? If $_POST["name"] == "" then the user submitted the form without typing their name

True (An empty string indicates no value was typed into the text field)

An attacker could use an XSS attack to redirect the user's browser to a malicious website.

True (JavaScript in an XSS attack can redirect a browser to any URL.)

Refer to table on 9.1.1 True or False? The UPDATE statement changes no one's GPA. UPDATE student SET gpa = 2.0 WHERE stu_id = 333;

True (Stu_id 333 does not exist)

True or False? The regex /run/ matches the string "pruning".

True (The characters "run" appear in consecutive order in "pruning".)

Referring to the figures above, if the user typed a space in the name field, the required attribute would allow the form to be submitted, but the server-side data validation would produce an error message.

True (The required attribute accepts a single space as input, but the PHP trim() function eliminates the space in the name. So, an error message is displayed.)

True or False? Loading footer.php from the animation above alone in a web browser results in a warning

True (footer.php is meant to work with header.php, but if footer.php is loaded in the web browser alone, the $currDate variable is not defined, and a warning is generated)

True or False? The students table is empty after the table is created.

True (need other SQL statements to insert data into the table)

True or False? The code below outputs 12. $greeting = "How are you?"; echo strlen($greeting);

True (strlen() counts every character in $greeting)

What is the SQL statement for the CRUD operation (1 word) Update

UPDATE

Must PHP statements be terminated by a semicolon?

Yes

Must every foreign key value come from an existing primary key value? Yes or No?

Yes

What argument is missing that makes the prepared statement select songs with artists that start with "Black"? $sql = "SELECT * from songs WHERE artist LIKE :artist"; $stmt = $pdo->prepare($sql); $stmt->execute(____);

["artist" => "Black%"] (An associative array's keys match the named parameters.)

Match anything except a vowel (a, e, i, o, u). /[___]/

^aeiou

$quiz = [ [ "question" => "Who is John Galt?", "answer" => "We are!", "points" => 5 ], [ "question" => "Who you gonna call?", "answer" => "Ghostbusters", "points" => 5 ], [ "question" => "What is the air speed velocity of an unladen swallow?", "answer" => "About 24 miles per hour", "points" => 10 ] ]; $quiz is an ______________. a) indexed array of associative arrays b) associative array of associative arrays c) associative array of indexed arrays

a

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); What shows are selected by the following query? SELECT * FROM shows; a) All shows b) Arrow c) No shows

a

How are these ordered? Arrow 8 action Community 6 comedy Grey's Anatomy 16 drama Parks and Recreation 7 comedy The Blacklist 5 drama a) ORDER BY title b) ORDER BY seasons c) ORDER BY genre

a

If Hamilton and Grit are the only books checked, what is the output? echo $_POST["books"][0]; a) Miranda b) Hamilton: The Revolution c) Miranda and Duckworth

a

If Hamilton and Grit are the only books checked, what is the output? echo count($_POST["books"]); a) 2 b) 1 c) 0

a

In PHP, an empty string is treated like a 0 when used as a number. Assuming no student has an ID of 0, what is output if the user submits the form without typing an ID, name, and GPA? a) was successfully inserted. b) Couldn't insert because ID 0 already exists. c) An exception error message.

a

Look at table on 8.6.5 What dates are selected? SELECT release_date FROM tv_show WHERE title = 'The Office'; a) No dates b) 2012-10-10 c) 2012-10-10 and 2009-04-09

a

Refer to table on 9.1.3 What is missing to set the release date to January 22, 2010 for shows that have 6 seasons? UPDATE tv_show SET _____ WHERE seasons = 6; a) release_date = '2010-01-22' b) release_date = 2010-01-22 c) release_date = 'Jan 1, 2010'

a

Refer to table on 9.1.3 What shows are updated? UPDATE tv_show SET release_date = '2017-12-25'; a) All shows b) No shows c) Arrow

a

Refer to table on 9.1.6 What is missing to delete only Community? DELETE FROM tv_show WHERE _____; a) show_id = 555 b) title = Community c) seasons = 6

a

Refer to table on 9.1.6 What shows are deleted? DELETE FROM tv_show; a) All shows b) No shows c) The SQL is syntactically incorrect because the WHERE clause is missing.

a

What does the code below output? sayGoodbye("Sam"); function sayGoodbye($name) { echo "Goodbye, $name"; } a) Goodbye, Sam b) Goodbye, $name c) Goodbye,

a

What is the title for the class with class_id 1002? a) English Composition b) African History c) Data Structures

a

What language is used to add new students to the students table? a) SQL b) RDBMS c) MySQL

a

switch ($item) { case "apple": case "orange": $fruits++; break; case "milk": $drinks++; case "cheese": $dairy++; break; case "beef": case "chicken": $meat++; break; default: $other++; } If $item is "Apple", what variables are incremented? a) $other b) $fruits c) Nothing is incremented.

a ("Apple" does not =="apple" or any other cases, so the default case is executed)

preg_match("/(.+) (.+) (.+)/", "zing zany zone", $matches); echo $matches[2]; a) zany b) zone c) zing zany zone

a ("zany" is remembered by the second set of parentheses and is in $matches[2])

What is the value of $_GET["comment"] for the query string below? http://localhost/order.php?name=Bob&howmany=1&comment=This+is+a+gift a) This is a gift b) This+is+a+gift

a ($_GET["comment"] is decoded, so plusses in the query string become spaces)

$quiz = [ [ "question" => "Who is John Galt?", "answer" => "We are!", "points" => 5 ], [ "question" => "Who you gonna call?", "answer" => "Ghostbusters", "points" => 5 ], [ "question" => "What is the air speed velocity of an unladen swallow?", "answer" => "About 24 miles per hour", "points" => 10 ] ]; What is missing to output the sum of the quiz points? $total = 0; foreach (__________) { $total += $q["points"]; } echo "Total points = $total";

a ($q is assigned each associative array element of $quiz)

The SQL statement below is used to select students with the last name "Smith". What is wrong with the statement ? SELECT first_name FROM student WHERE last_name = Smith; a) The literal Smith must be surrounded by quotes. b) first_name should be a table name. c) No students have the last name "Smith".

a ('Single' or "double" quotes must surround string literals)

preg_match("/\w+y/", "zing zany zone", $matches); echo $matches[1]; a) Notice message b) zing zany zone c) zany

a (No parentheses exist in the regex, so only $matches[0] is defined. The notice message indicates that offset 1 of the $matches array is undefined)

What regex matches the string "Regular Expression"? a) /Exp/ b) /exp/

a (Regular expressions are case sensitive, so "Exp" matches the capital "E" in "Expression")

$date1 = date_create("2015-10-12"); $date2 = date_create("2016-09-22"); $dateDiff = date_diff($date1, $date2); echo $dateDiff->y; a) 0 b) 1 c) 10

a (Sep 2016 is only 11 months away from Oct 2015)

What is $_SERVER["REQUEST_METHOD"] the first time a script is loaded in the web browser? a) GET b) POST

a (The browser sends an HTTP GET request the first time a script is loaded in the browser.)

What is wrong with the SQL statement below? SELECT gpa --FROM student; a) The FROM clause is a comment. b) The WHERE clause is missing. c) gpa should be a table name.

a (The double dashes preceding the FROM clause cause the RDBMS to ignore the FROM clause. The FROM clause is required in a SELECT statement)

What value is assigned to $x? $x = rand(5, 10); a) Random integer between 5 and 10 (inclusive) b) Random integer < 5 or > 10 c) 5 or 10

a (The rand() function produces a pattern of random numbers that eventually repeat but are useful for most applications)

What regex matches the string "boom"? a) /ba?oom/ b) /b\?oom/ c) /bo?m/

a (a? means the "a" may be missing)

Which statement generates a warning if util.php is not found? a) include "util.php"; b) require "util.php"; c) require "./util.php";

a (include statements generate a warning if the file is not found)

Which constant is illegally named? a) $A1_ b) _A1 c) TEST_23

a Constants may bot begin with a $

Which code segment produces a notice error message? a) $count = 2; echo $COUNT; b) $count = 2; ECHO $count; c) Both code segments produce notice errors.

a PHP variables are case-sensitive, so $COUNT is an uninitialized variable.

$date1 = date_create("2015-10-12 10:00:30"); $date2 = date_create("2016-09-22 20:05:00"); $dateDiff = date_diff($date1, $date2); echo "$dateDiff->h:$dateDiff->i:$dateDiff->s"; a) 10:4:30 b) 10:5:30 c) 0:0:0

a (20:05:00 is 10 hours, 4 minutes, and 30 seconds after 10:00:30)

Select the expression to complete the code below. $statement = $pdo->query("SELECT gpa FROM students"); foreach (_____ as $row) { echo "<p>$row[gpa]</p>"; } a) $statement b) $statement->fetch() c) $pdo

a (The PDOStatement object can be iterated over using a foreach loop.)

What numbers are output by the code segment? for ($c = 5; $c < 10; $c += 2) { echo $c; } a) 5, 7, 9 b) 5, 6, 7, 8, 9 c) Infinite loop

a (The loop terminates after $c is incremented to 11)

What value is $x?$x = preg_match("/c\/1/", "abc/123"); a) 1 b) 0

a (The regex matches "c/1". Because the forward slash character indicates the beginning and the ending of a regex, the backslash character must precede the forward slash (like this: \/) to match a forward slash)

Match only the letters a through f. /[___]/

a-f

Look at table on 8.4.12 What does this statement do? DELETE FROM shows;

all shows are removed

$medals = [ "USA" => 2681, "Soviet Union" => 1204, "China" => 526, "Japan" => 443 ]; What sorting function results in the array value... USA, Soviet Union, China, Japan

arsort($medals); ($medals is sorted in descending order based on number of medals)

$medals = [ "USA" => 2681, "Soviet Union" => 1204, "China" => 526, "Japan" => 443 ]; What sorting function results in the array value... Japan, China, Soviet Union, USA

asort($medals); ($medals is sorted in ascending order based on number of medals)

A new ____ is needed to store each student's address. a) table b) column c) row

b

CREATE TABLE faculty ( fac_id INTEGER AUTO_INCREMENT, last_name VARCHAR(50), first_name VARCHAR(50), dept_code VARCHAR(4), hire_date DATE NOT NULL, PRIMARY KEY(fac_id) ); INSERT INTO __A__ (__B__) VALUES (__C__); What should A be replaced with? a) fac_id b) faculty c) table_name

b

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); In what order are the shows retrieved by the following query? SELECT * FROM shows ORDER BY title; a) Grey's Anatomy, Arrow, The Blacklist, Parks and Recreation b) Arrow, Grey's Anatomy, Parks and Recreation, and The Blacklist c) The Blacklist, Parks and Recreation, Grey's Anatomy, Arrow

b

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); What shows are selected by the following query? SELECT * FROM shows WHERE seasons <= 10 AND seasons >= 5; a) All shows b) Arrow and Parks and Recreation c) Grey's Anatomy

b

How are these ordered? Arrow 8 action Community 6 comedy Parks and Recreation 7 comedy The Blacklist 5 drama Grey's Anatomy 16 drama a) ORDER BY seasons, genre b) ORDER BY genre, seasons c) ORDER BY genre, title

b

How are these ordered? The Blacklist 5 drama Community 6 comedy Parks and Recreation 7 comedy Arrow 8 action Grey's Anatomy 16 drama a) ORDER BY title b) ORDER BY seasons c) ORDER BY genre

b

Look at table on 8.6.5 What dates are selected? SELECT release_date FROM tv_show WHERE NOT title = 'The Office'; a) No dates b) All dates c) 2012-10-10

b

Look at table on 8.6.5 What dates are selected? SELECT release_date FROM tv_show WHERE title = 'Arrow'; a) No dates b) 2012-10-10 c) 2012-10-10 and 2009-04-09

b

The _____ data type is ideal for creating a column that stores a student's date of birth. a) DATETIME b) DATE

b

What does a developer with username "manning" type to start the mysql tool? a) mysql -p manning b) mysql -u manning -p

b

What does the below code output? sayHello("Sam"); sayHello("Juan", "Hola"); function sayHello($name, $greeting = "Hello") { echo "$greeting, $name\n"; } a) Hello, Sam Hello, Juan b) Hello, Sam Hola, Juan c) Hola, Sam Hola, Juan

b

What does the code below output? function special_nums() { return [3.142, 2.718, 1.618]; } list($pi, $euler, $phi) = special_nums(); echo $euler; a) 3.142 b) 2.718 c) 1.618

b

What file extension does a PHP script have? a) .html b) .php c) .png

b

What is Billy's GPA? a) 3.1 b) 2.5 c) 4.0

b

What is output when the user selects University of Arkansas? if ($_POST["team"] == "razorbacks") { echo "Woo Pig Sooie!"; } else { echo "Roll tide!"; } a) Woo Pig Sooie! b) Roll tide!

b

What is the value of $_POST["team"] if the user selects Texas A&M University? a) Texas A&M University b) Aggies c) Impossible

b

What numbers are output by the code segment? for ($x = 1; $x <= 3; $x++) { // outer loop for ($y = 2; $y <= 4; $y++) { // inner loop echo $y; } } a) 2, 3, 4 b) 2, 3, 4, 2, 3, 4, 2, 3, 4 c) 2, 3, 4, 5, 6, 7, 8, 9, 10

b

What row must be added to the enroll table to give Tye a C in the class with course_id 52? a) 555, 1001, C b) 555, 1004, C

b

Which loop always executes the loop body at least once? a) while b) do-while c) for

b

Which table should be modified to add an instructor? a) course b) class

b

What string does NOT match the regex /cat|bat|mat/? a) bbatt b) at c) mat

b ("at" does not match because "at" is not preceded by c, b, or m)

preg_match("/z(\w+)/", "zing zany zone", $matches); echo $matches[1]; a) zing b) ing c) ing zany zone

b ($matches[1] contains the first remembered match in parenthesis)

What regex matches the string "breaeak"? a) /bre+a+k/ b) /br(ea)+k/ c) /er|bk/

b ((ea)+ matches the string "ea" one or more times)

What value is assigned to $x? $x = round(12.6) + floor(3.7); a) 15 b) 16 c) 17

b (12.6 rounds to 13, and the floor of 3.7 is 3. 13 + 3 = 16)

What value is assigned to $x? $x = pow(2, 3); a) 6 b) 8 c) 9

b (2 to the power of 3 = 2 * 2 * 2 = 8)

What does the code segment output? $date1 = date_create("2015-10-12"); $date2 = date_create("2016-09-22"); if ($date1 > $date2) { echo "greater than"; } elseif ($date1 < $date2) { echo "less than"; } else { echo "same"; } a) greater than b) less than c) same

b (2015 is before 2016, so 2015-10-12 < 2016-09-22)

What regex matches the string "what?"? a) /what?$/ b) /what\?$/ c) /what$/

b (A backlash before ? matches a literal "?")

switch ($item) { case "apple": case "orange": $fruits++; break; case "milk": $drinks++; case "cheese": $dairy++; break; case "beef": case "chicken": $meat++; break; default: $other++; } If $item is "beef", what variables are incremented? a) $other b) $meat only c) $meat and $other

b (After incrementing $meat, the break statement stops executing code in the switch statement)

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); What number is returned by the following query? SELECT COUNT(*) FROM shows; a) 0 b) 4 c) 1

b (COUNT() counts the number of rows selected, and the table has 4 rows)

If the textarea below was added to the form in the animation above, what would be added to the query string when the form is submitted? <textarea name="comment">This is a gift</textarea> a) &comment=This is a gift b) &comment=This+is+a+gift

b (Form data is encoded, so spaces become plusses)

Choose the correct call to the function below. function sayGoodbye($name) { echo "Goodbye, $name"; } a) sayGoodbye(); b) SAYGOODBYE("Sam"); c) say_goodbye("Sam");

b (Function names are case-insensitive, but good practice is to call a function using the same case as the function's declaration)

Where should the data validation code be placed? if ($_POST["num"] == "") { echo "<p>You didn't type a number.</p>"; } a) Before if ($_SERVER["REQUEST_METHOD"] == "POST") { ... } b) Inside if ($_SERVER["REQUEST_METHOD"] == "POST") { ... } c) After if ($_SERVER["REQUEST_METHOD"] == "POST") { ... }

b (Only when the request method is POST should $_POST["num"] be checked for a number.)

The INSERT statement adds a student to the student table. How many clauses are in the INSERT statement? INSERT INTO student VALUES (888, 'Smith', 'Jim', 3.0); a) 1 b) 2 c) 3

b (The INSERT clause is followed by the VALUES clause)

Which column cannot have duplicate values? a) dept_code b) class_id c) credit_hrs

b (The class_id column is a primary key, and primary key values must be unique)

What condition makes the loop output even numbers 2 through 20? $c = 2; while (_____) { echo $c; $c += 2; } a) $c >= 20 b) $c <= 20 c) $c < 20

b (The last time this loop outputs a value is when $c is 20)

What value is assigned to $x? $x = sqrt(9); a) 0 b) 3 c) 9

b (The square root of 9 is 3)

What regex matches the string "that's easy"? a) /b?eas$/ b) /b?sy$/ c) /e+sy$/

b (b? matches a missing "b", and sy$ matches "sy" at the end of the string)

$quiz = [ [ "question" => "Who is John Galt?", "answer" => "We are!", "points" => 5 ], [ "question" => "Who you gonna call?", "answer" => "Ghostbusters", "points" => 5 ], [ "question" => "What is the air speed velocity of an unladen swallow?", "answer" => "About 24 miles per hour", "points" => 10 ] ]; What is output by the code below? echo $quiz[0]["points"]; a) Who is John Galt? b) 5 c) 10

b (the first question is 5 points)

The var_dump(variable) function outputs the data type of a variable. What is the output of the code below? $x = 1.23; var_dump($x); a) int(1.23) b) float(1.23) c) number(1.23)

b 1.23 has a decimal place, so 1.23 is a floating point number.

Which statement produces a parse error? a) $owner = "Pam's"; b) $owner = 'Pam's'; c) $owner = 'Pam"s';

b A single quote in a string delimited with single quotes must be escaped with a backslash: $s = 'Pam\'s';

Which statement is equivalent to const EMAIL = "[email protected]";? a) define("EMAIL") = "[email protected]"; b) define("EMAIL", "[email protected]"); c) EMAIL = "[email protected]";

b One difference between const and define() is that define() can create a constant name from a variable, and const cannot.

In the animation above, the query() method throws a PDOException indicating the MySQL error 1146 occurred because the test.students table does not exist. What MySQL error does the SELECT statement below cause? $sql = "SELECT gpa IN students"; a) 1054 - Unknown column name b) 1064 - Parsing error, bad syntax c) 1336 - Bad value being inserted

b (A SELECT statement uses "FROM" before the table name, not "IN". A syntactically incorrect or improperly formatted SQL statement causes a 1064 error.)

Referring to the figure above, what is $_SERVER["REQUEST_METHOD"] when the user clicks the "Guess" button a second time? a) GET b) POST

b (Every time the user presses "Guess", the form posts back to the script, setting the request method to POST.)

What regex matches the string "PHP"? a) /php/ b) /php/i

b (The "i" makes the regular expressions case insensitive, so the regex matches "php" or "PHP")

What value is $x?$x = preg_match("/regex/", "regular expression"); a) 1 b) 0

b (The characters "regex" do not appear in consecutive order in "regular expression")

Refer to figure 8.8.4 After saving Tom, what is output if the user attempts to save a second student named Mandy using ID 744? a) Mandy was successfully inserted. b) Couldn't insert Mandy because ID c) 744 already exists. An exception error message.

b (The execute() method throws a PDOException with error code 1062 when a duplicate key (stuid 744) is used in the INSERT statement.)

CREATE TABLE faculty ( fac_id INTEGER AUTO_INCREMENT, last_name VARCHAR(50), first_name VARCHAR(50), dept_code VARCHAR(4), hire_date DATE NOT NULL, PRIMARY KEY(fac_id) ); INSERT INTO __A__ (__B__) VALUES (__C__); What should B be replaced with? a) fac_id, last_name, first_name, dept_code, hire_date b) last_name, first_name, dept_code, hire_date c) fac_id

b (fac_id is auto-increment)

Select the function call to complete the code below. $statement = $pdo->query("SELECT gpa FROM students"); while ($row = _____) { echo "<p>$row[gpa]</p>"; } a) $statement->query() b) $statement->fetch() c) $statement->fetchAll()

b (fetch() fetches a single row from the selected rows)

What string does NOT match the regex /w+hy/? a) why b) hy c) wwwhy

b (w+ means at least 1 "w" must exist)

Assuming warnings and error messages are set to output to the browser, what would be displayed in the browser if require in the figure above was replaced with include, and color.php was not in the current directory? a) "That's so random!" b) A warning message only c) A warning message and fatal error message

c

CREATE TABLE faculty ( fac_id INTEGER AUTO_INCREMENT, last_name VARCHAR(50), first_name VARCHAR(50), dept_code VARCHAR(4), hire_date DATE NOT NULL, PRIMARY KEY(fac_id) ); INSERT INTO __A__ (__B__) VALUES (__C__); What should C be replaced with? a) 123, 'Wallace', 'William', 'HIST' b) 'Wallace', 'William', 'HIST' c) 'Wallace', 'William', 'HIST', '2017-07-10'

c

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); The DATEDIFF() function returns the number of days between two dates. What shows are selected by the following query? SELECT * FROM shows WHERE DATEDIFF('2016-08-01', releaseDate) > 365 * 10; a) All shows b) No shows c) Grey's Anatomy

c

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); The YEAR() function extracts the year from the given date. What is selected by the following query? SELECT title, YEAR(releaseDate) FROM shows; a) Grey's Anatomy 2005 b) 2005, 2012, 2013, 2009 c) Grey's Anatomy 2005, Arrow 2012, The Blacklist 2013, Parks and Recreation 2009

c

CREATE TABLE shows ( showId INTEGER, title VARCHAR(45), seasons INTEGER, releaseDate DATE, PRIMARY KEY (showId) ); INSERT INTO shows VALUES (111, 'Grey\'s Anatomy', 12, '2005-03-27'), (222, 'Arrow', 5, '2012-10-10'), (333, 'The Blacklist', 4, '2013-09-23'), (444, 'Parks and Recreation', 7, '2009-04-09'); What shows are selected by the following query? SELECT * FROM shows WHERE seasons < 5; a) All shows b) Arrow and The Blacklist c) The Blacklist

c

How are these ordered? Grey's Anatomy 16 drama Parks and Recreation 7 comedy Community 6 comedy Arrow 8 action The Blacklist 5 drama a) ORDER BY title b) ORDER BY seasons c) ORDER BY release_date

c

How many rows would the students table have if a new student were added to the table? a) 2 b) 3 c) 4

c

Look at table on 8.6.5 What shows are selected? SELECT * FROM tv_show WHERE (seasons >= 6 AND seasons <= 10) OR release_date = '2005-03-27'; a) All shows b) Arrow and Parks and Recreation c) Grey's Anatomy, Arrow, and Parks and Recreation

c

Look at table on 8.6.5 What shows are selected? SELECT * FROM tv_show WHERE seasons < 6; a) All shows b) Arrow and The Blacklist c) The Blacklist

c

Look at table on 8.6.5 What shows are selected? SELECT * FROM tv_show WHERE seasons <= 10 AND seasons >= 6; a) All shows b) Arrow and Parks and Recreation c) Grey's Anatomy

c

Refer to table on 9.1.3 What is missing to set the seasons to 1 and genre to "fantasy" for shows released after 2010? UPDATE tv_show SET _____ WHERE YEAR(release_date) > 2010; a) genre = 'fantasy' AND seasons = 1 b) genre = fantasy, seasons = 1 c) genre = 'fantasy', seasons = 1

c

Refer to table on 9.1.3 What shows are updated? UPDATE tv_show SET seasons = seasons + 1 WHERE genre = 'comedy'; a) All shows b) Parks and Recreation c) Parks and Recreation and Community

c

Refer to table on 9.1.6 What shows are deleted? DELETE FROM tv_show WHERE genre = 'drama'; a) All shows b) Grey's Anatomy c) Grey's Anatomy and The Blacklist

c

Referring to the animation above, why might the PDO constructor throw an exception? a) The username and password are correct. b) The MySQL server is running on localhost. c) The "test" database does not exist.

c

What DSN value is omitted from the animation above? a) DSN prefix b) host c) port d) dbname

c

What condition causes the for loop to output the numbers 100 down to 50, inclusively? for ($c = 100; ______; $c--) { echo $c; } a) $c < 50 b) $c > 50 c) $c >= 50

c

What values are required to create a PDO object? a) Username and password only b) Hostname only c) Hostname, database name, username, and password

c

Which expression evaluates to true if the user does not check any checkboxes? if (_______) { echo "No titles selected"; } a) count($_POST["books"]) == 0 b) !isset($_POST["books[]"]) c) !isset($_POST["books"])

c

Which row contains correct values for a new Data Structures class? a) 1003, 52, 1, MWF 2pm, SCI 200 b) 1004, COMP, 1, MWF 2pm, SCI 200 c) 1004, 52, 1, MWF 2pm, SCI 200

c

Which row contains correct values for a new history course? a) 51, HIST, Indian Culture, 3 b) 53, COMP, Indian Culture, 3 c) 53, HIST, Indian Culture, 3

c

Which statement terminates the script if util.php is not found in the current directory? a) include "./util.php"; b) require "util.php"; c) require "./util.php";

c

switch ($item) { case "apple": case "orange": $fruits++; break; case "milk": $drinks++; case "cheese": $dairy++; break; case "beef": case "chicken": $meat++; break; default: $other++; } If $item is "milk", what variables are incremented? a) $other b) $drinks only c) $drinks and $dairy

c

What regex matches the string "sleep like a baby"? a) /^like/ b) /like$/ c) /^sleep/

c ("sleep" is at the beginning of the string.)

What value is assigned to $x? $x = max(8, -10, 21, 4); a) -10 b) 8 c) 21

c (21 is larger than 8, -10, and 4)

What is $c when the loop terminates? $c = 10; while ($c <= 20) echo $c; $c += 5; a) 15 b) 20 c) The loop never terminates.

c (Even though $c += 5 is indented, only echo $c; is in the loop body because the while loop does not have { } surrounding both statements. Therefore, 10 is output repeatedly in an infinite loop)

What is the output? preg_match("/\w+y/", "zing zany zone", $matches); echo $matches[0]; a) zing b) zing zany c) zany

c (The full match contains all consecutive word characters that end in "y")

What is $c when the loop terminates? $c = 10; while ($c <= 20); { echo $c; $c += 5; } a) 25 b) 20 c) The loop never terminates.

c (The semicolon after the while condition creates an infinite loop. While loops should never have a semicolon after the condition.)

What is wrong with the SQL statement below? SELECT first_name from student a) "from" must be "FROM". b) The WHERE clause is missing. c) A terminating semicolon is missing.

c (The semicolon indicates the end of a SQL statement. Some RDBMSs do not require terminating semicolons)

What value is assigned to $x? $x = sin(M_PI / 2); a) 0 b) 0.5 c) 1

c (The sine of the angle π/2 is 1)

$quiz = [ [ "question" => "Who is John Galt?", "answer" => "We are!", "points" => 5 ], [ "question" => "Who you gonna call?", "answer" => "Ghostbusters", "points" => 5 ], [ "question" => "What is the air speed velocity of an unladen swallow?", "answer" => "About 24 miles per hour", "points" => 10 ] ]; What outputs the answer to the second question? $q = $quiz[1]; echo _______; a) "<h2>", $q[answer], "</h2>" b) "<h2>$q['answer']</h2>" c) "<h2>$q[answer]</h2>"

c (an array's key value is not quoted inside of a quoted string)

What does the code below output? $nums = [6, -3, 10, 2]; echo find_max($nums); function find_max($nums) { $max = $nums[0]; foreach ($nums as $n) { if ($n > $max) { $max = $n; } } return $max; } a) 6 b) -3 c) 10

c (find_max() returns the value of $max, which contains the largest number in the $nums array)

Which expression evaluates to true if the user does not select any radio buttons? if (_______) { echo "No team selected"; } a) $_POST["team"] == "" b) isset($_POST["team"]) c) !isset($_POST["team"])

c (isset() returns false if no team is selected, and !false = true)

What does the PHP code output? $test = "adios"; echo "$test test"; a) $test test b) $adios test c) adios test

c The $test variable is output as "adios"

Which variable is illegally named? a) $a1_ b) $null c) $2b_

c variables may not star with a digit after $

Assuming the students table has only the three students in the animation above, what is output by the code below? $sql = "SELECT name FROM students WHERE stuId = 999"; $statement = $pdo->query($sql); $row = $statement->fetch(); if ($row) { echo $row["name"]; } else { echo "Not found"; } a) A PDOException is thrown. b) Sue c) Not found

c (No row is returned by fetch() since no student has stuId 999. So if ($row) is FALSE. If a row were returned, if ($row) would be TRUE.)

What is output if the user attempts to save Deshawn with ID 777, but the table students does not exist? a) Deshawn was successfully inserted. b) Couldn't insert Deshawn because ID 777 already exists. c) An exception error message.

c (Referencing a table in SQL that does not exist causes the MySQL error 1146. So the PDOException is rethrown, causing an exception error message to display.)

If the students table contains 10 students and 7 students have a GPA less than 3.0, how many names does the foreach loop output? $sql = "SELECT name FROM students WHERE gpa >= 3.0"; $statement = $pdo->query($sql); foreach ($statement as $row) { echo "<p>$row[name]</p>"; } a) 10 b) 7 c) 3

c (The SELECT statement selects the 3 students with at least a 3.0 GPA, and the foreach loop iterates over all 3 rows.)

What string does NOT match the regex /grea*t/? a) gret b) greaaat c) grat

c (grat is missing an "e")

What are the first and last numbers output by the code segment? $c = 100; while ($c > 0) { echo $c; $c -= 10; } a) 100 and 0 b) 90 and 0 c) 100 and 10

c (loop terminates when $c is 0. At the start of the last iteration, $c is 10. $c is then decremented to 0. The loop condition is checked: 0< is false, and the loop terminates)

function count_nums(...$nums) { $total = 0; foreach ($nums as $n) { if ($n % 2 == 0) { $total++; } } return $total; } What is the function call of the return value 3

count_nums("one", "two", "three"); (When a string value % 2 is computed, the string is first converted to a number. Strings with leading text are converted to 0, and 0 % 2 is 0)

function count_nums(...$nums) { $total = 0; foreach ($nums as $n) { if ($n % 2 == 0) { $total++; } } return $total; } What is the function call of the return value 2

count_nums(0, -2, 3); (2 of the arguments are even numbers)

function count_nums(...$nums) { $total = 0; foreach ($nums as $n) { if ($n % 2 == 0) { $total++; } } return $total; } What is the function call of the return value 4?

count_nums(2, 4, 6, 8); (All 4 arguments are even numbers)

function count_nums(...$nums) { $total = 0; foreach ($nums as $n) { if ($n % 2 == 0) { $total++; } } return $total; } What is the function call of the return value 0

count_nums(5, 15); (no arguments are even numbers)

Enter the value assigned to $x in each code segment. $quote = "I am Spartacus!"; $x = strpbrk($quote, "bcd");

cus! (The "c" is the only character in the quote, and strpbrk() returns the string beginning at "c")

What is the PHP code for the string... Sun

date_format($date, "D")

What is the PHP code for the string... 20:04

date_format($date, "G:i")

What is the PHP code for the string... Sep 12

date_format($date, "M d")

What is the PHP code for the string... 9/12/14

date_format($date, "n/j/y")

What is the PHP code for the string... Fri, 12 Sep 2014 20:04:15-0500

date_format($date, "r")

What is the PHP code for the output, given that $x = 12; 9 12 0

echo "9 $x 0"; ($x's value is substituted into the double-quoted string)

What is the PHP code for the output, given that $x = 12; 9 $x

echo "9 /$x"; (/$ outputs a dollar sign in a double-quoted string)

What is the PHP code for the output, given that $x = 12; Warning

echo "9$x0"; (no variable $x0 exists and the PHP engine outputs a warning message when outputting a variable that is not initialized)

What is the PHP code for the output, given that $x = 12; 9120

echo "9{$x}0"; (curly braces around a variable ensure proper variable interpolation)

What is the PHP code for the output, given that $x = 12; 9 $x 0

echo '9 $x 0'; (Single-quoted strings do not perform variable interpolation, so $x remains in the output)

What is the PHP code for the output, given that $x = 12; 9 12

echo '9 ' . $x; ($x is concatenated to the back of "9" and a space)

What is the PHP code for the output, given that $x = 12; 9 /

echo '9 //'; // is converted to a single backslash in single and double-quotes strings

USA, Soviet Union, Japan, China

krsort($medals); ( $medals is sorted in descending order based on the country name)

China, Japan, Soviet Union, USA

ksort($medals); ($medals is sorted in ascending order based on the country name)

$quote = "Every man dies. Not every man lives."; preg_replace("/\w+ /", "one ", $quote);

one one dies. one one lives

Enter the SQL statement to display all the tables in the music database.

show tables

client-side (or front-end) refers to

technologies that run in the web browser like HTML, CSS, and JavaScript.

Server-side (or back-end) refers to

technologies that run on the web server like PHP, Python, Node.js, etc. and databases

True or False? The mysql tool must be supplied a username and password to connect to MySQL server.

true

Enter the SQL statement to select the music database.

use music;

Pass-by-_______ assigns a copy of an argument to the parameter

value

Enter the value assigned to $x in each code segment. $quote = "I am Spartacus!"; if (strcmp($quote, "I am TIRED!") < 0) { $x = "yes"; } else { $x = "no"; }

yes (strcmp() returns a value less than 0 because the two strings are identical until "S" and "T", and "S" is less than "T")

Add Tim's grade to the $grades array. $grades = ["Beth" => "B", "Lance" => "C", "Jose" => "A"]; $grades[_____] = "D";

"Tim"

What argument is missing? $sql = "SELECT * from songs WHERE artist LIKE :artist"; $stmt = $pdo->prepare($sql); $stmt = $pdo->bindValue(_____, "Black%"); $stmt->execute();

"artist" ( When the parameterized SQL uses named parameter markers, bindValue() uses a named parameter identifier to bind the value to the parameter.)

Output Jose's grade from the $grades array. $grades = ["Beth" => "B", "Lance" => "C", "Jose" => "A"]; echo ______;

$grades["Jose"]

Complete the foreach loop to output all the names and grades in the $grades array. $grades = ["Beth" => "B", "Lance" => "C", "Jose" => "A"]; foreach ($grades as __________) { echo "$name's grade is $grade.\n"; }

$name=>$grade

Complete the foreach loop to output each name. $names = ["Beth", "Lance", "Jose"]; foreach (_______ as $name) { echo "$name\n"; }

$names

Output "Jose" from the $names array. $names = ["Beth", "Lance", "Jose"]; echo _____;

$names[2]

Complete the code to create a reference parameter called $s. function insertDashes(____) { for ($i = 0; $i < strlen($s); $i++) { if ($s[$i] == " ") { $s[$i] = "-"; } } } $words = "Pass by reference"; dashes($words); echo $words; // Pass-by-reference

&$s (Reference parameters have & in front of the parameter name.)

What is output by the code below? function negateArray(&$x) { for ($i = 0; $i < count($x); $i++) { $x[$i] *= -1; } } $nums = [6, -7, 0]; negateArray($nums); echo $nums[0];

-6 (Since $nums is passed by reference, each value of $nums is multiplied by -1, so 6 becomes -6, -7 becomes 7, and 0 remains 0)

What compound assignment operator makes $points become 2.5? $points = 5; $points ___ 2;

/= ($points /= 2 is the same as: $points = $points / 2 = 5 / 2 = 2.5.)

What does $x = $x = 0; if ($x > 10) { $x = 1; }

0 (Since 0 is not > 10, the if statement is false, and the if block does not execute)

What does $x = $a = 2; if ($a == "2") { if ($a === "2") { $x = 1; } else { $x = 0; } }

0 (2 is == to "2", but 2 is not === to "2" because 2 and "2" are different data types. So, the else block executes)

Refer to the $tweet below. $tweet = "Missing @sam1 and @jan4prez! Don't forget me! #eurotravel #bff"; What number outputs "#eurotravel" to the browser? preg_match_all("/#\w+/", $tweet, $matches); echo $matches[0][_____];

0 (The first string matched (#eurotravel) is put in $matches[0][0].)

What does $x = $x = 30; if ($x < 0) { $x++; } elseif ($x < 10) { $x--; } else { $x = 0; }

0 (The first two if statements evaluate to false, so the else block executes)

Match only the digits 0 through 5. /[___]/

0-5

"3" - "2too" + "sixty6" = ?

1

What does $x = if ("history" < "math") { $x = 1; } else { $x = 0; }

1 (The ASCII value for "h" is < "m" so "history" < "math" is true)

What is output by the code below? function swapValues($x, $y) { $temp = $x; $x = $y; $y = $temp; } $a = 10; $b = 20; swapValues($a, $b); echo $a;

10

Look at table on 8.7.5 What error does this SQL statement produce? UPDATE shows SET genre = 'realtiy' WHERE seasons >6;

1054: Unknown column name

Look at table on 8.7.5 What error does this SQL statement produce? INSERT into shows VALUES (999, 'Stranger Things', 2, '2016-07-15');

1062: Duplicate entry for primary keys

Look at table on 8.7.5 What error does this SQL statement produce? UPDATE title ='The Office' WHERE showId = 999;

1064: Parsing error, bad syntax

$points = 10; $points--; $points + 2 = ?

11

Look at table in 8.6.2 What data does this SELECT statement select SELECT show_id FROM tv_show;

111 222 333

Look at table in 8.6.2 What data does this SELECT statement select SELECT show_id, release_date, seasons FROM tv_show;

111, 2005-03-27, 12 222, 2012-10-10, 6 333, 2009-04-09, 7

Look at table on 8.7.5 What error does this SQL statement produce? INSERT into shows VALUES (888, 'Stranger Things', 2);

1136: Number of values given in INSERT does not match number of columns

Look at table on 8.7.5 What error does this SQL statement produce? INSERT into showsTable VALUES (888, 'Stranger Things', 2, '2016-07-15');

1146: Table does not exist

Look at table in 8.6.2 What data does this SELECT statement select SELECT seasons, title FROM tv_show;

12, Grey's Anatomy 6, Arrow, 7, Parks and Recreation

5 + 3 ** 2 = ?

14

(3 + 4) % 5 = ?

2

Refer to the $tweet below. $tweet = "Missing @sam1 and @jan4prez! Don't forget me! #eurotravel #bff"; What is $numMatches? $numMatches = preg_match_all("/@\w+/", $tweet, $matches);

2 (The 2 strings "@sam1" and "@jan4prez" match the regex)

What argument is missing? $sql = "SELECT * from songs WHERE title LIKE ? AND year > ?"; $stmt = $pdo->prepare($sql); $stmt = $pdo->bindParam(1, $title); $stmt = $pdo->bindParam(_____, $year); $stmt->execute();

2 (bindParam(2, $year) binds $year to the second question mark parameter marker.)

Add the name "Stacy" to the end of the $names array. $names = ["Beth", "Lance", "Jose"]; $names[___] = "Stacy";

3

"4e3" + 1 = ?

4001

What is the last number output by the loop? $c = 0; do { $c++; echo $c; } while ($c < 5);

5 (The numbers 1, 2, 3, 4, 5 are output. After 5 is output, the loop's condition is false, and the loop terminates.)

Enter the value assigned to $x in each code segment. $quote = "I am Spartacus!"; $x = strpos($quote, "part");

6 (strpos() returns the index of "part" in the quote, which begins at index 6)

What value is $points? $points = 2; $points *= 3 + 1;

8 ($points = $points * (3 + 1) = 2 * (3 + 1) = 2 * 4 = 8)

What conditional operator makes the do-while loop output 10, 20, 30, ..., 100? $c = 10; do { echo $c; $c += 10; } while ($c ___ 100);

<= (The loop executes when $c is 100 and terminates after $c is incremented to 110.)

What is missing from the parameterized SQL? $sql = "SELECT * from songs WHERE title = _____"; $stmt = $pdo->prepare($sql); $stmt = $pdo->bindValue(1, "Twist"); $stmt->execute();

? (What argument is missing that makes the prepared statement select songs with artists that start with "Black"? $sql = "SELECT * from songs WHERE artist LIKE :artist"; $stmt = $pdo->prepare($sql); $stmt->execute(____);)

Refer to the $tweet below. $tweet = "Missing @sam1 and @jan4prez! Don't forget me! #eurotravel #bff"; What is output to the browser? preg_match_all("/@\w+/", $tweet, $matches); echo $matches[0][1];

@jan4prez (The second string matched (@jan4prez) is put in $matches[0][1].)

Server and hosting environment

Issues regarding network throughput, cloud storage, virtualization, hardware constraints, multithreading, and data redundancy.

True or False 2 > 10 || 1 > 2

False

True or False A single INSERT statement can insert only one row into a table.

False

True or False? Every student is enrolled in at least one class. True False

False

True or False? If another row is added to the student table, another column must also be added

False

What is the math constant for... Euler's constant (2.718281828459)

M_E

What is the math constant for... Natural logarithm of 2 (0.69314718055995)

M_LN2

What is the math constant for... Base 10 logarithm of E (0.43429448190325)

M_LOG10E

What is the math constant for... Value of π (3.1415926535898)

M_PI

What is the math constant for... Square root of 2 (1.4142135623731)

M_SQRT2

What is the SQL statement for the CRUD operation (2 word) Retrieve

SHOW TABLES

INSERT INTO students (stuId, name) VALUES (888, 'Wang');

this is syntactically correct

"123" !== "123"

False

!(2 > 10 && 5 > 0)

True

3 + 5 * 2 = ?

13


Related study sets

ACC 3313 EXAM 3 (Chapt 13,14) - Binod Guragai

View Set

Wonders Vocabulary- Unit 6 Week 3- Resources

View Set

Chapter 10: Assessment of High Risk Pregnancy NCLEX

View Set

Grammar in Context from UN #HeForShe Campaign: Gender Equality is Your Issue Too by Emma Watson. Present, Past, Present Perfect Tenses in Active and Passive Voice https://quizlet.com/_unz6i

View Set

Semester 3 Test 1, Sem 3 Unit 2, Sem 3 Unit 3, Sem 3 Test 4, Sem 3 Unit 5, Sem 3 Unit 6

View Set

Micro Ecnomics CH. 1 homework questions

View Set

Chapter 9: Sculpture / Chapter 10: Site Specific Art

View Set

Classical Sociological Theory Quiz Compilation

View Set

Artificial Intelligence - Week 1

View Set