CTI 110 Final!
All operating systems mentioned above
"PHP runs on different platforms (Windows, Linux, Unix, etc.)"
<?php ?>
A PHP script should start with ___ and end with ___:
row
A ________ in a table represents a relationship among a set of values
Entity Relationship
A diagram showing the entities (tables) within the database, the attributes (fields) associated with those entities, and how the entities relate to one another.
list($firstName, $lastName) = explode (":", $someValue);
A file named member-list.txt contains the string "Mary:King" on a single line. Assume you already have written the following code: $listFile =fopen("member-list.txt","r"); $someValue = fgets($listFile); fclose($listFile); Which of the following lines must you add to correctly parse the string and store the first and last name into variables $firstName and $lastName?
tables
A relational database consists of a collection of:
False
An Entity Relationship Diagram lists specific fields for a table and document the tables, fields and relationships.
print ("<p>$row['empID'], $row['jobTitle']</p>");
Assume an application uses the following query: $userQuery="SELECT empID, jobTitle FROM personnel WHERE lastName='Smith'"; $result = mysqli_query($connect, $userQuery); and then uses the following loop heading: while $row=mysqli_fetch_assoc($result) Which statement below should appear inside the loop to process the values in the result s
The comma
Assume member-list.txt contains the following two lines of text: Mary,King Peter,Jones What is being used as a delimiter in this file?
Mary:King Peter:Jones Ann:Porter Dennis:Smith
Assume somefile.txt contains the following text on two lines: Mary:King Peter:Jones What will the file contain after the following instructions are executed? $someFile =fopen("somefile.txt","a"); fputs($someFile, "Ann:Porter\n"); fputs($someFile, "Dennis:Smith\n"); fclose($someFile);
Ann:Porter Dennis:Smith
Assume somefile.txt contains the following text on two lines: Mary:King Peter:Jones What will the file contain after the following instructions are executed? $someFile =fopen("somefile.txt","w"); fputs($someFile, "Ann:Porter\n"); fputs($someFile, "Dennis:Smith\n"); fclose($someFile);
34567 cleaner, then 23456 sales, then 45678 sales
Assume that the personnel table contains three records of employees with these empID's and job titles: 23456 sales 34567 cleaner 45678 sales How would these three records be ordered in the result set of the following query? SELECT empID jobTitle from personnel ORDER BY jobTitle, empID
Definition
CREATE DATABASE is an SQL Data _____________________ language command.
10
Consider the following code: $listFile =fopen("number-list.txt","r"); $someValue = fgets($listFile); fclose($listFile); Assume number-list.txt contains the following three lines of text: 10 25 15
describe personnel;
Consider the following code: $listFile =fopen("number-list.txt","r"); $someValue = fgets($listFile); fclose($listFile); Assume number-list.txt contains the following three lines of text: 10 25 15
rectangle shapes
Entities are used in modeling relationships among tables. They are represented by:
A semi-colon ;
Every PHP statement must end with
one-to-many
For each customer in the Customers table, there can be 0 or more related orders in the Orders table. For each order in the Orders table, there can be only one related customer in the customers table. This is an example of a __________________ relationship type.
Use \", for example "He said \"OK\""
How do you display a double quote inside a string that begins and ends with double quotes?
1
How many lines will these statements store in the file referenced by the variable fputs($someFile, "Test"); fputs($someFile, "One, two, three");
2
How many values will the user submit each time this form is used? <form action = "process.php" method = "post" > <p>Color: <select name="color"> <option>Red</option> <option>Blue</option> <option>Green</option> </select></p> <p>Quantity:<input type="text" size="10" name = "qty"></p> <input type="submit" value="Submit Order" /> </form>
Foreign Key
In a relationship, when a primary key from one table is also defined in a second table, the field is referred to as a ____ in the second table.
Column
In a visual representation of a table, a field is shown as a
The code sent to discount.php can be extracted from $_POST['code']
Look at the following HTML form. Which description is correct? <form action = "discount.php" method = "post" > <p>Please enter your discount code: <input type = "text" size = "20" name = "code" > </p> <input type = "submit" value = "Process" > </form>
other
Look at the following statement. What is the name of the database? $connect=mysqli_connect('localhost', 'this', 'that', 'other');
FALSE
MySQL is another language that is added to SQL to organize database.
.php
PHP files have a default file extension of ______
Server-side
PHP is _________ scripting language
Server Computer
PHP scripts are executed on _______
A dollar sign $
PHP variable names must begin with
<p>Allow 20 hours for study</p>
Read this carefully. What HTML code is generated by the print statement? $numCourses = 4; $studyTime = $numCourses * 5; print ("<p>Allow $studyTime hours for study</p>");
<p>Allow 0 hours for study</p>
Read this carefully. What HTML code is generated by the print statement? $numCourses = 4; $studyTime = $numcourses * 5; print ("<p>Allow $studyTime hours for study</p>");
Data Manipulation Language
The SQL Language used to retrieve and manipulate data in the table such as to insert, delete, and update data is:
Data Definition Language
The SQL statements ALTER TABLE Customers ADD Email varchar(30) is an example of the:
Both c & d
The ______________ key are identification tags for each row and must never be the same for more than one record.
Logical error
The arithmetic is wrong in the following PHP statement (it should be $price - $discount). Is this a syntax error or a logical error? $salePrice = $discount - $price;
DELETE
What MYSQL Command is used to remove a record from a table?
The data remains available after a program has ended.
What is important about persistent data?
UPDATE
What is the correct MySQL command to modify the values stored in a record?
Show databases
What is the statement to list the available databases?
The print statement will not display correctly.
What is wrong with the following PHP code segment? $amount = 10.00; $tax = $amount * 0.07; $total = $tax + $amount; print ("<p>TOTAL COST: $number_format($total, 2)</p>");
To use fputs() you must open the file for write or append operations.
What is wrong with this code? $listFile =fopen("member-list.txt","r"); fputs($listFile, $newMember); fclose($listFile);
280
What value is stored in $inventory after these three PHP instructions are executed? $inventory = 320; $unitsSold = 40; $inventory = $inventory - $unitsSold;
16
What value is stored in $result after this PHP instruction is executed? $result = (6 + 10) * (5 - 4);
Michael
What value will be stored in the jobTitle field of this record after this query is executed? (be careful) INSERT INTO personnel (empID, jobTitle, firstName, lastName, hourlyWage) VALUES (67890, 'Michael', 'Peter', 'cleaner', 12.50)
Error
What will be the output of the following PHP code ? <?php var $one = 1; var $two = 2; print "$one / $two * $one / $two * $two"; ?>
Hello World
What will be the output of the following PHP code ? <?php $hello = "Hello World"; $bye = "Bye"; print $hello;"$bye"; ?>
Error
What will be the output of the following PHP code ? <?php $4four = 4; $3three = 3; $2two = 2; print "$4four + $3three / $2two - 1"; ?>
1 / 2 + 3 / 4
What will be the output of the following PHP code ? <?php $on_e = 1; $tw_o = 2; $thre_e = 3; $fou_r = 4; print "$on_e / $tw_o + $thre_e / $fou_r"; ?>
Error
What will be the output of the following PHP code ? <?php $on$e = 1; $tw$o = 2; $thre$e = 3; $fou$r = 4; print "$on$e / $tw$o + $thre$e / $fou$r" ; ?>
Error
What will be the output of the following PHP code ? <?php one = 1; two = 2; three = 3; four = 4; print "one / two + three / four"; ?>
My name is Bobbob
What will be the output of the following code? <?php $foo = 'Bob'; $bar = $foo; $bar = "My name is $bar"; print $bar; print $foo; ?>
3
What will be the output of the following php code? <?php $num = "1"; $num1 = "2"; print $num+$num1 ; ?>
FROM
Which MySQL clause is used with a SELECT command to specify which table is to be searched?
ORDER BY
Which SQL keyword is used to sort the result-set?
SELECT
Which SQL statement is used to extract data from a database?
A database contains tables and a table contains records and fields.
Which is correct?
Databases are not as sophisticated as text files.
Which of the following is NOT correct regarding databases?
$num = 111;
Which of the following php statement/statements will store 111 in variable num?
Only (iii)
Which of the following php statement/statements will store 111 in variable num? i) int $num = 111; ii) int mum = 111; iii) $num = 111; iv) 111 = $num;
CREATE TABLE
Which of the following types of SQL statements is not a DML statement?
SELECT
Which of the following types of statements does not modify the data in a table?
'Smythe' will be matched but 'Smith' and 'Smithson' will not be matched
Which of the last names will be matched by the WHERE clause in the following query? SELECT empID from personnel WHERE lastName LIKE 'Sm_th_'
ID
Which one of the following attribute can be taken as a primary key ?
$score3
Which one of the following is an acceptable name for a PHP variable?
BETWEEN
Which operator is used to select values within a range?
SELECT empID FROM personnel WHERE hourlyWage > 15.00 AND hourlyWage <= 18.00
Which query will correctly obtain the empID of employees whose hourly wage is greater than 15.00 and no more than 18.00?
A program can open any number of files at the same time for any operations as needed (reading, writing or appending).
Which statement is true?
SELECT COUNT(lastName) FROM personnel WHERE lastName='Smith'
Which statement will generate the number of people with last name 'Smith' in the personnel table?
If the file already exists, the existing file will be replaced by the new file.
Why should you be careful about opening a file for write operations?
SELECT FirstName FROM Persons;
With SQL, how do you select a column named "FirstName" from a table named "Persons"?
SELECT * FROM Persons WHERE FirstName='Peter';
With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?
SELECT * FROM Persons WHERE FirstName LIKE 'a%';
With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?
select * from personnel;
Write out the statement to retrieve all the data from the Personnel.
Append operations
Your Web page provides a form for users to add their names to a membership list, stored in a text file. You are writing a program to process the form submission. How should your program open the file?