2016-06-10 80 views
0

下面我有一些代码和一个错误。所以首先我会解释我的代码是干什么的。在我的脚本的安装过程中,它所做的一件事是在编写配置文件之前,它将SQL文件拉出并运行到数据库中。下面的代码可以工作,但它会多次出现严格的标准错误,然后会破坏我创建配置文件的结果,并且由于它们只是给出了错误,所以js脚本被破坏。我不知道该如何解决这个问题,并且已经想出了一些可能会看到这个并意识到这是他们以前见过的东西,这实际上是一个简单的解决方案。循环内的脚本标准

Strict Standards: mysqli::next_result(): There is no next result set. Please, call 
mysqli_more_results()/mysqli::more_results() 

代码:

function TestConnection($host, $user, $pass, $data) { 
     $link = mysqli_connect($host, $user, $pass, $data); 
     if (!$link) { 
      echo "Error: Unable to connect to MySQL." . PHP_EOL; 
      echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; 
      echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; 
      exit; 
     } 
     foreach(glob(root_p."/install/SQL/create/*.sql") as $sqlfile) { 
      $command = file_get_contents($sqlfile); 
      $link->multi_query($command); 
      while ($link->next_result()) { 
       ; 
      } //flush 
      $link->query($command); 
     } 
     CreateConfig($host, $user, $pass, $data); 
     mysqli_close($link); 
    } 

回答

1

你尝试什么错误消息告诉你?

喜欢的东西:

while ($link->more_results()) { 
    $link->next_result(); 
} 

或者你可以尝试:

while ($link->more_results() && $link->next_result()) { 
+0

我真的不理解的错误消息。我会在一分钟内尝试 –