QuickForm with DB problem
| From: | l Burnerheimerton | Date: | Sat, 19 Nov 2005 10:13:49 +0000 |
| Subject: | QuickForm with DB problem | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-22002@lists.php.net to get a copy of this message | ||
I copied this form form a working form page. Now it
throws an error. Here's the code:
if ($form->validate()) {
$form->process('process_data', false);
header("Location: nextpage.htm");
exit;
}
function process_data ($v) {
// connection string
$table_name = 'registration';
$table_fields = array(...);
$table_values = array(...);
$sth = $db->autoPrepare($table_name, $table_fields,
DB_AUTOQUERY_INSERT);
$res =& $db->execute($sth, $table_values);
}
$form->display();
The error is:
"Call to a member function on a non-object in ... line
72" which is the following line from the above code:
$sth = $db->autoPrepare($table_name, $table_fields,
DB_AUTOQUERY_INSERT);
I assume that means $db is not "visible" in that
function. I have added print_r($db) inside the
function process_data and it shows "Undefined
variable: db". I added "require_once("DB.php");"
inside the function and it still showed undefined
variable.
I used print_r($db) in the form part of the page and
it displays the $db array properly. But it somehow is
not working inside the function to process_data. I
have verified the DB.php and Connection string works.
Any ideas?
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com