dfritter4 Posted July 12, 2006 Share Posted July 12, 2006 im working with phpBB forums and doing some mods to it.at one point in my code, i need to go from updating one table in the database, to two different tableshere is where its submitting the information to the database: (my code is between the // random quote mod)[code]// random quotes mod$sqldata = "SELECT * FROM " . QUOTES_TABLE;if(!$result = $db->sql_query($sqldata)){ message_die(CRITICAL_ERROR, "Could not query quotes information in admin_board", "", __LINE__, __FILE__, $sqldata);}else{ while( $row = $db->sql_fetchrow($result) ) { $quotes_name = $row['quotes_name']; $quotes_value = $row['quotes_value']; $default_quotes[$quotes_name] = isset($HTTP_POST_VARS['submit']) ? str_replace("'", "\'", $quotes_value) : $quotes_value; $quotes[$quotes_name] = ( isset($HTTP_POST_VARS[$quotes_name]) ) ? $HTTP_POST_VARS[$quotes_name] : $default_quotes[$quotes_name]; } } // random quotes mod//// Pull all config data//$sql = "SELECT * FROM " . CONFIG_TABLE;if(!$result = $db->sql_query($sql)){ message_die(CRITICAL_ERROR, "Could not query config information in admin_board", "", __LINE__, __FILE__, $sql);}else{ while( $row = $db->sql_fetchrow($result) ) { $config_name = $row['config_name']; $config_value = $row['config_value']; $default_config[$config_name] = isset($HTTP_POST_VARS['submit']) ? str_replace("'", "\'", $config_value) : $config_value; $new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name]; if ($config_name == 'cookie_name') { $new['cookie_name'] = str_replace('.', '_', $new['cookie_name']); } // Attempt to prevent a common mistake with this value, // http:// is the protocol and not part of the server name if ($config_name == 'server_name') { $new['server_name'] = str_replace('http://', '', $new['server_name']); } if( isset($HTTP_POST_VARS['submit']) ) { $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' WHERE config_name = '$config_name'"; //random quotes mod $sqldata = "UPDATE " . QUOTES_TABLE . " SET quotes_value = '" . str_replace("\'", "''", $quotes[$quotes_name]) . "' WHERE quotes_name = '$quotes_name'"; // random quotes mod if( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql); } if( !$db->sql_query($sqldata) ) { message_die(GENERAL_ERROR, "Failed to update random header quotes for $quotes_name", "", __LINE__, __FILE__, $sqldata); } } }[/code]now it is reading the info from the database for the CONFIG_TABLE but when you press submit to update any changed information, it just brings up the old data (it never updates it)theres obviously something wrong with the way ive done this, and i was hoping someone could tell me how to make sure both the CONFIG_TABLE and the QUOTES_TABLE were updated in that one pass.the [code]if( isset($HTTP_POST_VARS['submit']) )[/code] is where it starts to submit to the database Quote Link to comment Share on other sites More sharing options...
fenway Posted July 12, 2006 Share Posted July 12, 2006 I'm not really sure why your running that replace to remove escaped quotes; however, it would be hard to run these update statements together, since they're in unrelated tables, AFAIK. Quote Link to comment Share on other sites More sharing options...
dfritter4 Posted July 12, 2006 Author Share Posted July 12, 2006 but is it possible? Quote Link to comment Share on other sites More sharing options...
fenway Posted July 12, 2006 Share Posted July 12, 2006 I don't think so... why would you want to, anyway? Quote Link to comment Share on other sites More sharing options...
dfritter4 Posted July 12, 2006 Author Share Posted July 12, 2006 because the data type for the config_value field is a varchar(255) and the text im going to need to store in the database is going to be a very very very long string. and id have to either create a new database table and store it there, or change the data type of the config_value field to a longtext type. and the people that are going to be validating my mod might not like me changing a default datatype for a configuration table. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 12, 2006 Share Posted July 12, 2006 I understand that, but why try to do it in a single statement? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.