PHP – The Beginning

This has got to be one of THE most important messages sent out, ever… At least to me it is! from: here From: ras…@io.org (Rasmus Lerdorf) Subject: Announce: Personal Home Page Tools (PHP Tools) Date: 1995/06/08 Message-ID: #1/1 X-Deja-AN: 104053006 organization: none newsgroups: comp.infosystems.www.authoring.cgi Announcing the Personal Home Page Tools (PHP Tools) version 1.0. These [...]

PHP heredoc syntax

from: here I sometimes need a reminder. And sometimes a good example page goes away (see 'Why I Save Articles' above). Therefore, here is my reminder, with credits. Without Variables: <?php $str = <<<DEMO This is a demo message with heredoc. DEMO; echo $str; ?> With Variables: <?php $name = "Max"; $str = <<<DEMO Hello [...]

PHP Insert & Update Functions

function mysql_insert($table, $toAdd){ $fields = implode(array_keys($toAdd), ','); $values = "'".implode(array_values($toAdd), "','")."'"; # better $q = 'INSERT INTO `'.$table.'` ('.$fields.') VALUES ('.$values.')'; $res = mysql_query($q)OR die(mysql_error()); return true; //– Example of usage //$tToAdd = array('id'=>3, 'name'=>'Yo', 'salary' => 5000); //insertIntoDB('myTable', $tToAdd) } function mysql_update($table, $update, $where){ $fields = array_keys($update); $values = array_values($update); $i=0; $query="UPDATE ".$table." SET [...]