Such a question, the query does not work in this way $mysqli->query("..."); , instead you have to use mysql_query("..."); Here is the whole code:

  function settings() { $data = array('nameproject' => 'name', 'titleproject' => 'title', 'emailadmin' => 'email', 'minlogin' => 'minlogin', 'maxlogin' => 'maxlogin', 'minwithdraw' => 'minsum', 'maxwithdraw' => 'maxsum', 'refpercent' => 'refpercent', 'exchange' => 'exchange', 'a1' => 'auth', 'r1' => 'reg', 'https' => 'https', 'stopwork' => 'stopwork' ); foreach ($data as $key => $value) { if (!empty($_POST[$key])) { mysql_query("UPDATE settings SET ".$value." = '".$_POST[$key]."'"); // вот и проблемное место, почему не работает $mysqli->query("..."); ? } else { mysql_query("UPDATE settings SET ".$value." = ''"); } } } 
  • one
    Tell someone about the variable scope. - Ipatiev
  • @ Ipatiev Then in my function, I need to reconnect to the database? - user309502
  • It is better to pass the connection to a function, or use the procedural style mysqli_query( $query ) . - Arnial

2 answers 2

in fact, this is some kind of nonsense, the function should still read the config even if it is not in the function body .... because the function can take any values ​​from the outside, but return only those that are already declared or returned by the function itself, the only thing what you could not do at all config file

  • Actually, this is a comment of some kind, but not the answer - Ipatiev

It was necessary in the function to connect the data file with the database

 function settings() { include('../config.php'); // вот $data = array('nameproject' => 'name', 'titleproject' => 'title', 'emailadmin' => 'email', 'minlogin' => 'minlogin', 'maxlogin' => 'maxlogin', 'minwithdraw' => 'minsum', 'maxwithdraw' => 'maxsum', 'refpercent' => 'refpercent', 'exchange' => 'exchange', 'a1' => 'auth', 'r1' => 'reg', 'https' => 'https', 'stopwork' => 'stopwork' ); foreach ($data as $key => $value) { if (!empty($_POST[$key])) { mysql_query("UPDATE settings SET ".$value." = '".$_POST[$key]."'"); // вот и проблемное место, почему не работает $mysqli->query("..."); ? } else { mysql_query("UPDATE settings SET ".$value." = ''"); } } } } 
  • This is the worst possible option - Ipatyev