Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP/SQL多重插入不起作用_Php_Jquery_Mysql_Sql_Insert - Fatal编程技术网

PHP/SQL多重插入不起作用

PHP/SQL多重插入不起作用,php,jquery,mysql,sql,insert,Php,Jquery,Mysql,Sql,Insert,我不能一次插入两个标签。 它只插入其中的1个(在本例中,它插入第一个) 问题是因为您返回了第一个mysql\u查询,其余的将不会执行。请尝试这样删除它 function addNewUser($username, $password, $email){ $time = time(); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){

我不能一次插入两个标签。 它只插入其中的1个(在本例中,它插入第一个)


问题是因为您
返回了第一个
mysql\u查询
,其余的将不会执行。请尝试这样删除它

function addNewUser($username, $password, $email){
      $time = time();
      /* If admin sign up, give admin user level */
      if(strcasecmp($username, ADMIN_NAME) == 0){
         $ulevel = ADMIN_LEVEL;
      }else{
         $ulevel = USER_LEVEL;
      }
    $datumregistrationbla = date("d.m.Y");
      $q = "INSERT INTO ".TBL_USERS." (username, password, email, userlevel, register_date) VALUES ('$username', '$password', '$email', '$ulevel', '$datumregistrationbla')";
      mysql_query($q, $this->connection);
      $q = "INSERT INTO `post` (`post_id`, `from`, `to`, `betreff`, `text`, `datum`, `active`) VALUES ('', 'Fuchsfeuer', '$username', 'Test', 'Test2', '$datumregistrationbla', '0')";
      mysql_query($q, $this->connection);
   }
请忘记使用mysql,因为它已被弃用,并且在PHP7中已被删除
尝试使用或

function addNewUser($username, $password, $email){
      $time = time();
      /* If admin sign up, give admin user level */
      if(strcasecmp($username, ADMIN_NAME) == 0){
         $ulevel = ADMIN_LEVEL;
      }else{
         $ulevel = USER_LEVEL;
      }
    $datumregistrationbla = date("d.m.Y");
      $q = "INSERT INTO ".TBL_USERS." (username, password, email, userlevel, register_date) VALUES ('$username', '$password', '$email', '$ulevel', '$datumregistrationbla')";
      mysql_query($q, $this->connection);
      $q = "INSERT INTO `post` (`post_id`, `from`, `to`, `betreff`, `text`, `datum`, `active`) VALUES ('', 'Fuchsfeuer', '$username', 'Test', 'Test2', '$datumregistrationbla', '0')";
      mysql_query($q, $this->connection);
   }