lunac Posted June 8, 2009 Share Posted June 8, 2009 Ok, I have an application with a section to manage users. For some reason my routine for updating level permissions is not working. Can anyone figure out what I did wrong? Here's the code: $x = mysqlSelect($_tables['modules']); while($y = @mysql_fetch_assoc($x)){ $mods[] = $y; } foreach ($mods as $modu){ //check if module value exist otherwise add it $check = usr($modu['level'], $_POST['id']); if($check != ''){ lib_executeQuery("UPDATE " . $_tables['usersmeta'] . " set meta_value='" . $_POST[$modu['level']] ."' WHERE user_id='" . $_POST['id'] . "' AND meta_key='" . $modu['level'] . "'"); } else { $post['user_id'] = $_POST['id']; $post['meta_key'] = $modu['level']; $post['meta_value'] = $_POST[$modu['level']]; mysqlInsert($post,$_tables['usersmeta']); } Here are the supporting functions: function mysqlInsert($array,$table){ unset($array['Submit']); $keys = array_keys ($array); $values = array_values ($array); $kquery = join("','",$keys); $kquery = str_replace("'","",$kquery); $vquery = join("','",$values); $query = "insert into $table (" . $kquery . ") values ('" . $vquery . "')"; lib_executeQuery($query) or die(mysql_error()); } function lib_executeQuery($query,$dbLink=""){ // Execute an SQL query passed to this function if($dbLink){ $link = $dbLink; } else { $link = lib_databaseConnect(); } $dbResult = mysql_query($query, $link) or die ("Database Class: MySQL Error: " . mysql_error() ); return $dbResult; } Link to comment https://forums.phpfreaks.com/topic/161442-solved-problems-updating-fields-in-db-with-current-code-please-help/ Share on other sites More sharing options...
lunac Posted June 11, 2009 Author Share Posted June 11, 2009 I hate to bump, but I've waited all week..... anyone Link to comment https://forums.phpfreaks.com/topic/161442-solved-problems-updating-fields-in-db-with-current-code-please-help/#findComment-854020 Share on other sites More sharing options...
lunac Posted June 13, 2009 Author Share Posted June 13, 2009 Never mind -- the code is flawless. The problem turned out to be elsewhere. Thanks for all those who took a look. Link to comment https://forums.phpfreaks.com/topic/161442-solved-problems-updating-fields-in-db-with-current-code-please-help/#findComment-855248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.