【问题标题】:Script Standard within loop [duplicate]循环内的脚本标准[重复]
【发布时间】:2016-06-10 13:33:42
【问题描述】:

下面我有一些代码和一个错误。所以首先我将解释我的代码是做什么的。在我的脚本的安装过程中,它所做的一件事就是在编写配置文件之前提取 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);
    }

【问题讨论】:

    标签: php sql mysqli


    【解决方案1】:

    您是否尝试过错误消息告诉您的内容?

    类似:

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

    或者你可以试试:

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

    【讨论】:

    • 我并没有真正理解错误信息。一分钟后我会在这里尝试
    猜你喜欢
    • 2013-03-22
    • 2017-12-17
    • 1970-01-01
    • 2013-08-24
    • 2021-02-08
    • 2021-04-05
    • 2022-05-17
    • 1970-01-01
    • 2021-08-21
    相关资源
    最近更新 更多