Put library and config info in the library directory under the base directory.
the config file (pc_config.php) has specific info about the project.
the library file (pc_lib.php) does the initialization and has standard functions.
Some of the library functin I created and use are:
DEBUG functions
pc_debug([$var=''] [,$label='___']) display debug information
looks at config variable $c_debug to = "on" in pc_config.php.
Command line ?debug=on will also activate the debugger for the session (or "off" will stop it)
call like: pc_debug(); with no parameters will show session, request and cookie arrays
pc_debug($varname,'$varname 123'); remember to use single quote, not double quote for label
pc_debug($_SESSION,'$_SESSION[] 242'); I like to put the variable name and line number in label
pc_debug($row,'$row[] 217'); To see the record (row) from the sql table just loaded
FORM functions
pc_f_text($name,[$value=""]) display text box, with value if presented
pc_f_radio($name,$value [,$default=""]) if $default = $value it is checked
pc_f_check($name [,$default=""]) if checked, value = "yes"
pc_f_select_sql($name,$sql [,$default=""]) displays dropdown select box from sql
pc_f_select($name,$values [,$default=""] [,$displays=""]) values and displays are comma delimited
if $default = $value it is selected , displays optional, different than values
SQL functions
pc_query($sql [,$label]) does query and error reporting
pc_sql_1field($field,$table,$where) get just one field from db
DATE functions
pc_ymd_mdy($MySQLDate) retury mm/dd/yyyy from yyyy/mm/dd entered (from MySql format)
pc_mdy_ymd($MDYDate) returns yyyy/mm/dd from mm/dd/yyyy entered (to MySql format)
Misc functions
pc_dencr($text,$de [,$key2=""]) decrypt or encrypt "d" or "e", extra key2 optional
pc_text2image($text) display image of the text, such as for email address
$sql="SELECT * from filex WHERE f_id = '$the_id'";
$result=pc_query($sql,143);
-or-
$result=pc_query($sql,99143); // if label > 99000 will show debug (actual sql command)
Then I extract the results into array $row such as:
while($row =mysql_fetch_array($result,1)){
echo $row['f_address'];
}
All variables, tables and field names should be lower case. Use _ (underscore) to make it more readable.An experienced expert PHP MySQL programmer has to be efficient to get the project done fast, correct and affordable.
For an experienced PHP programmer, click here