Hi there,
so i have a database table with each row representing a form value for the website's configuration. i create and process the form using php. when i go to update the database, the changes do not take affect. (manually checking using phpMyAdmin)
using firephp, i have traced the values to be updated throughout the script, and they contain the expected values at each step i check them. the update queries all return true, and the queries all look properly formatted. using "or die(mysql_error())" in conjunction with mysql_query() has no effect either.
ive also been googleing for about two days now trying to track this one down, but no luck. this has become somewhat frustrating, because everything appears like it should be working, except that it isnt! (two quite different things! argggg!:mad🙂 any help with this is greatly appreciated! Thanks for your time!
im running:
windows XP professional (32 bit)
Apache 2.2.3
php 5.2.0
mysql 5.0.2*
firefox 3 with firebug 1.3.2 / firephp 0.2.4
so heres some code:
//function that processes the submitted values
//takes $_POST as its argument
function processForm($post){
if($this->loadElements()){
$firephp = FirePHP::getInstance(true);
$firephp->log($this->elements, "before loop", FirePHP::INFO);
foreach($this->elements as &$element){
if($element->hasRules){
if($element->validate($post[$element->name])){
$element->setValue($post[$element->name]);
}
}else{
$element->setValue($post[$element->name]);
}
}
$firephp->log($this->elements, "after loop", FirePHP::INFO);
return $this->save($this->elements);
}
}
//function that performs the DB update
function save($elements){
$firephp = FirePHP::getInstance(true);
$database = Database::getDatabase();
$firephp->log($elements, "in save, just recieved elements", FirePHP::INFO);
$results = array();
$qs = array();
foreach($elements as $element){
$q = "UPDATE ".TBL_CONSTANTS
." SET `value` = '".mysql_escape_string($element->value)."'"
." WHERE `name` = '".$element->name."' LIMIT 1";
$qs[] = $q;
$results[] = $database->query($q);
}
$firephp->log($qs, "querys", FirePHP::INFO);
$firephp->log($results, "results of db calls", FirePHP::INFO);
$firephp->log($elements, "after db calls", FirePHP::INFO);
if(in_array(false, $results)){
return false;
}else{
return true;
}
}
i didn't include the firephp output in this post in consideration of space.
for those interested, i included a .zip of my class/object structure. the functions posted above reside in configForm.php and act on configFormElements, which are extended by booleanElement, TextElement, and SelectElement.