Lecture 22 - SQL update, Errors settings with PHP, PHP include

A couple more things today...

SQL UPDATE


UPDATE table
    SET col1 = val1, col2 = val2, ...
    WHERE condition;
          

SQL (template)


UPDATE grades
    SET grade = 4.0
    WHERE netId = "kmthayer";
          

SQL (example)

UPDATE changes all rows where the condition is true.

HTML error codes with PHP


          header("HTTP/1.1 400 Invalid Request");
          header("Content-type: text/plain");
          
  • To give a non 200 (status OK) html response, use the header function.
  • In case of an error, you may need two calls to the header function, once to set the error code, and the second time to set the Content-Type.

PHP Error mode


          error_reporting(E_ALL);
          

This command makes PHP report more errors (sort of like use strict in javascript).

Cloud9 does not have the strict error checking on by deafult.

PHP include


          include("otherPhpFile.php");
          

include runs code from another php file. It works the same as if you just copied the code from the other file and pasted it where the include was.