Here is the test we are using. It's something we came up with pretty quick, to weed out some candidates.
I'm sure it's not the greates and can be much improved, but it's working well for us.
Mysql Questions
1 - You need a column type which will be able to store time and date in the range 1900-01-01 - 2199-12-31. Which column should you choose for this range?
a. DATETIME
b. TIMESTAMP
c. Either DATETIME or TIMESTAMP
d. Neither DATETIME nor TIMESTAMP will work for this range of dates.
2 ? You have the following table:
mysql> DESCRIBE keywords;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| article_id | int(11) | | PRI | 0 | |
| keyword | varchar(20) | | PRI | | |
+------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
You want to find all articles that contain both the keywords 'MySQL' and '4.0'. How can you do this in one query?
a. By using the BIT_COUNT() function in your SELECT
b. By using the FIND_IN_SET() function in the WHERE part of the SELECT
c. You cannot do this in MySQL
d. You write a query where you join the table with itself
3 - What is MySQL AB?
a. An upcoming version of MySQL that includes new table types
b. The company that develops and promotes the MySQL suite of programs
c. A MySQL client for use on UNIX platforms
d. A form-based front-end for generating reports based on data in a MySQL server
4 - What is purpose of the mysqldump program ?
a. it is used to resolve mysql core dumps and sending bug reports
b. it is used for low-level interaction with MySQL table data
c. it is used to dump table structure and content in text format
d. it is used to flush all tables prior to shutting down the MySQL serve
5 - Suppose you have the following tables :
mysql> DESCRIBE Country;
+----------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------+------+-----+---------+-------+
| Code | char(3) | | PRI | | |
| Name | char(52) | | | | |
| Capital | int(11) | YES | | NULL | |
+----------------+------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> DESCRIBE City;
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+----------------+
| Id | int(11) | | PRI | NULL | auto_increment |
| Name | char(35) | | | | |
| Country | char(3) | | | | |
| Population | int(11) | | | 0 | |
+------------+----------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
The tables are related through Capital in Country to Id in City and Code in Country to Country in City
Which rows will the following query return?
SELECT Country.Name, Capital FROM City, Country WHERE Capital = Id;
a. It will return all rows from the Country table, with or without corresponding Capitals in City
b. No rows, it will result in an error
c. It will return all rows from the City table with or without corresponding Capital entries in the Country table
d. It will return the number of rows in Country multiplied by the number of rows in City
e. It will return all rows from the Country table that have corresponding Capitals in the City table
6 ? You encounter a corrupt table in MySQL. How do you resolve the issue?
PHP Questions
7 ? What is the purpose of the PHP function print_r() ?
a. used to automatically display text with line breaks
b. displays information about a variable in a way that's readable by humans.
c. is identical to ?echo?
d. outputs a string of text in html format
8 ? Which of these is an invalid use of the PHP function substr() ?
a. substr(?abcdef?,1);
b. substr(?abcdef?,-1,3);
c. substr(1,?abcdef?);
d. substr(?abcdef?,0);
9 ? Using the PHP function date() , and assuming $time is the current time as a unix timestamp, how would you convert $time into the format ?25-11-2004 23:01? ?
a. date(?D-M-Y h:a?,$time);
b. date(?d-m-Y H:i?,$time);
c. date($time,?D-M-Y h:a?);
d. date($time,? d-m-Y H:i?);
10 ? You have just upgraded your version of PHP and you have noticed that a GET variable you were using in one of your pages is now coming up blank. What could be the cause, assuming your code has not been modified?
a. the new version you are using doesn?t support GET variables
b. the new version you are using will only allow GET variables when using the special variable $_GET[]
c. the configuration option register_globals is now set to OFF
d. all of the above
11 ? When using the PHP function header() to redirect a user to another location, what must you always remember?
a. redirects of this type will not work in Netscape
b. never use exit() after the header function or your redirect will not work properly
c. always use exit() after the header function to prevent executing of code after the redirect
d. you may not redirect to a SSL-enabled page (ie.
https://)
12 ? What is the purpose of the php.ini file?
a. contains list of global variables
b. this file doesn?t exist
c. is the default configuration file of PHP
d. this file is no longer supported past PHP3
13 ? What is the value of $x, after the following PHP statement ?
$a=1; $b=3; $c=5;
if ($a = $b) {
$x = 100;
}
elseif ($b > $c) {
$x = 50;
}
elseif ($b < $a) {
$x = 42;
}
elseif ($a > $c) {
$x = 20;
}
a. $x = 100;
b. $x = 50;
c. $x = 42;
d. $x = 20;
14 ? Your PHP script returns you the error ?Warning: mysql_connect(): Host not allowed?. How do you resolve the problem?
15 ? Write a block of PHP code to output every fifth (5th) line of a text file. To help you, here are some functions you might want to use:
fopen -- Opens file or URL
Description
resource fopen ( string filename, string mode [, int use_include_path [, resource zcontext]])
fopen() binds a named resource, specified by filename, to a stream. If filename is of the form "scheme://...", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme. If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file.
fclose -- Closes an open file pointer
Description
bool fclose ( resource handle)
The file pointed to by handle is closed.
Returns TRUE on success or FALSE on failure.
The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().
fgets -- Gets line from file pointer
Description
string fgets ( resource handle [, int length])
Returns a string of up to length - 1 bytes read from the file pointed to by handle. Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, the length defaults to 1k, or 1024 bytes.
If an error occurs, returns FALSE.
feof -- Tests for end-of-file on a file pointer
Description
bool feof ( resource handle)
Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.