Phorm™ v3.5.2
Copyright © 2005 Holotech Enterprises.
Logging to a MySQL Database:
You can have Phorm log form contents to a MySQL database. A basic knowledge of MySQL is assumed; there are a number of good tutorials and references available if you would like to learn. To log to a MySQL database, define the following variables:
| $PHORM_MYDBV |
The name of a file containing host, user name, password and database name for a MySQL database to log to.
|
| $PHORM_MYTABLE |
The name of the table to log the form contents in.
|
| $PHORM_MYVARS |
A string containing the variables to log to the MySQL database.
|
Database Variables File
The file named in $PHORM_MYDBV must be in the same format as the configuration files, and contain the following variable definitions:
| $DHost |
The server that the database is hosted on. |
| $DUser |
The user name to log in as. |
| $DPass |
The password to log in with. |
| $DBase |
The name of the database to connect to. |
It is not necessary to put these in a separate file -- you can simply put them in your configuration file. If you do this, there is no need to define $PHORM_MYDBV.
Note that if Phorm is not running under your user ID, the file named in $PHORM_MYDBV must be world-readable.
$PHORM_MYVARS Format
The format for $PHORM_MYVARS is "col_name=var_name, col_name=var_name,...." For example:
$PHORM_MYVARS = "Name=name, Email=PHORM_FROM, Comments=comments";
Note: Do not put the dollar sign in front of the variable name.
Logging to Multiple Tables
If you wish to log to more than one table, $PHORM_MYTABLE and
$PHORM_MYVARS can be defined as arrays:
$PHORM_MYTABLE[1] = "Customers";
$PHORM_MYVARS[1] = "CustomerID=ID, FirstName=FName, LastName=LName";
$PHORM_MYTABLE[2] = "Orders";
$PHORM_MYVARS[2] = "CustomerID=ID, OrderID=OrderID, Total=OrderTotal";
There is a one-to-one correspondence between the elements of $PHORM_MYVARS and $PHORM_MYTABLE. That is,
$PHORM_MYVARS[1] will be used with $PHORM_MYTABLE[1], and so on. If there are more elements in one array
than the other, the extra elements will be ignored. If you are only making one entry to
one table, it is not necessary to define these variables as arrays.
Obtaining auto_increment Values
If you are inserting into a table that has a column with the auto_increment attribute, the
value of this column for the record you just inserted will be in $PHORM_MYSQLID. If $PHORM_MYTABLE is an array,
$PHORM_MYSQLID will be also - in other words $PHORM_MYSQLID[1] would have the value for $PHORM_MYTABLE[1], etc.
"Error in your SQL Syntax"
If you are using a version of PHP prior to 3.0.6, you may have problems if the data being logged contains a '
(single quote) character. If this is happening, you will get a message stating "MySQL
says: You have an error in your SQL syntax". To fix this, add the following line to your
phormconfig.php file:
$PHORM_QUOTES = True;
0101000001101000011011110111001001101101010010010111001101000011011011110110111101101100