

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A php quiz focusing on php basics, arrays, and mysql. It includes questions about php operators, variable declarations, data types, type casting, and array manipulation. The quiz also covers mysql database connection and querying.
Typology: Quizzes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CSCI 2910 PHP Intro/Array/MySQL Quiz Name: ________________________________ Spring 2007
a.) + b.) & c.) ^ d.) ~ e.) – f.). g.) : h.) >
a.) a boolean b.) a float c.) an integer d.) a string e.) code doesn't force a declaration
a.) null b.) 0 c.) 48 d.) 49 e.) None of the above
foreach ($a as $b => $c) { ...loop code... };
if (value >= 0) document.write ("The value equals " + value + ".\n");
if ($value >= 0) print "The value equals ".$value.".\n";
a.) make the PHP code of your scripts visible to the client like JavaScript. b.) declare global variables visible to all other functions. c.) declare a special data type used for random numbers. d.) declare a variable that remains declared for the duration, but is visible only within its function. e.) create an array of fixed length.
Use the following array declaration for the next three problems. $links = array('etsu'=>'http://www.etsu.edu', 3=>'http://www.yahoo.com', 'what'=>'http://www.whatis.com');
p r i n t " A r r a y e l e m e n t 3 i s { $ l i n k s [ 3 ] } " ; OR p r i n t " A r r a y e l e m e n t 3 i s ". $ l i n k s [ 3 ] ;
a.) 'etsu' b.) 3 c.) 'what' d.) Can't be predicted
a.) 0 b.) 1 c.) 4 d.) Can't be predicted
Use the following code as a reference for problems 12 through 16. The numbers along the left side are line numbers and are included only as a reference. They are not part of the code.
1: <?php 2: $conn = mysql_connect ("localhost", "zxyx999", "12345"); 3: mysql_select_db("zxyx999", $conn); 4: $result = mysql_query("SELECT * FROM timetable ORDER BY COURSE", $conn); 5: $count=0; 6: while($record = mysql_fetch_array($result, MYSQL_ASSOC)) 7: { 8: print "
Record {$count}:
\nuse zxyx999; -- selecting the database to use
Performing the query "SELECT * FROM timetable ORDER BY COURSE;"
There is a semi-colon missing from the end of the line of code.
In line 2, the MySQL database username and password is visible.
$index contains the field/column names from the table output from the query performed in line 4. The argument MYSQL_ASSOC in the mysql_fetch_array() function call in line 6 forces the index values of the array to be the field names, not integer values 0, 1, 2, etc.