CS174
Chris Pollett
Sep 27, 2010
Which of the following statements is true?
function my_fun($foo) { /* some code*/}$foo is passed by reference.
$_SESSION["test"]=37; /* sets the test session variable*/ echo $_SESSION["test"];
('Toyota', 'Corolla', '1970-01-01')
mysql -uroot -pwhat_password_is
show databases;
use dbname;
show tables;
GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES on dbname.* TO username@127.0.0.1 IDENTIFIED BY 'password';
mysql -uusername -ppassword
CREATE DATABASE my_nifty_db;
CREATE TABLE customer ( cust_id int(5) NOT NULL, name VARCHAR(50), title CHAR(3), PRIMARY KEY(cust_id) );
DROP TABLE customer;
DROP DATABASE my_nifty_db;
select col1, col2, col3 from table1, table2, table 3 where condition_holds;
select FNAME, LNAME from EMPLOYEE where SALARY > 10000;
SELECT T1.FIELD_NAME_1 AS NAME1, ..., T1.FIELD_NAME_N AS NAME_N, ..., TM.FIELD_NAME_N AS SOME_NAME FROM T1, T2, ..., TM WHERE T1.FIELD_NAME_j = some value [OR|AND] ... T1.FIELD_NAME_k = TJ.FIELD_NAME_wThe first line lists the columns we want, the second line lists the tables to use, the last line lists the conditions that must be met by the returned row (join conditions).
INSERT INTO table_name VALUES ('col1_value', 'col2_value', 'col3_value');
DELETE FROM table_name WHERE cond;
UPDATE table_name SET column='value' WHERE cond;
$db = mysql_connect($host, $uname, $pword);
mysql_select_db("cars");
$query ="SELECT * FROM Corvettes"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); $num_fields = mysql_num_fields($result); for($j = 1; $j <= $num_rows; $j++) { $row = mysql_fetch_array($result); print $row[0].$row["some_attr"]. "<br />"; }