PHP将值传递给MySQL存储过程调用获取错误mysqli_stmt :: bind_param()的参数计数错误

时间:2017-04-12 09:29:32

标签: php mysql call

我在PHP到MySQL存储过程问题上摸不着头脑,我在MySQL中有一个存储过程,等待两个输入参数。我试图通过我们的PHP代码调用该过程,传递它们通过HTML表单收到的2个变量。但我一直低于错误:

PHP警告:第26行/var/www/html/admin.php中mysqli_stmt :: bind_param()的参数计数错误,引用:..... admin.php  PHP警告:mysqli_error()期望在第27行的/var/www/html/admin.php中给出1个参数0,参考文献:http://...../admin.php

我的PHP代码如下所示,我无法找到它失败的原因:

 <?PHP  
    if (isset($_POST['Submit1'])) {
        $ServerSet = $_POST['ServerSet'];
        $Time = $_POST['Time'];

        if ( (strcasecmp ($ServerSet, 'A') == 0) Xor (strcasecmp ($ServerSet, 'B') == 0) ) {
                $servername = "localhost";
                $username = "appm";
                $password = "appm";
                $dbname = "ITD_infra";

                // Create connection
                $conn = new mysqli($servername, $username, $password, $dbname);
                // Check connection
                if ($conn->connect_error) {
                    die("Connection failed: " . $conn->connect_error);
                } 

            if (empty($Time)) {
                print "Fit A B and Time null";  
                print " Server is $ServerSet";
                $stmt = $conn->prepare("call ext_swing_update_v2(?, null)");       
                $stmt->bind_param($ServerSet);
                $stmt->execute() or die("Call fail: ".mysqli_error());
                $conn->close();
            }

            else {
                print "Both time and server not null";
                print " $ServerSet and $Time";
                $stmt = $conn->prepare("call ext_swing_update_v2(?,?)");
                $stmt->bind_param($ServerSet, $Time);                 
                $stmt->execute() or die("Call fail: ".mysqli_error());
                $conn->close();
            }
        }
        else {
            print "Server string not match";  
        }
    }

?>

    <Form Name="form1" method = "POST" Action= "admin.php" >           
        <br>
        <br>
        <br>
        <h2>  Infra Admin Page </h2>
        <br>
        <b>Give live external server set as A or B below: </b>
        <br>

        <br>
         Server Set:
         <INPUT TYPE = "Text" NAME = "ServerSet">
         <br>
         Time is in format of YYYY-MM-DD HH:MM:SS, HH is 24hr.
        <br>
         Time:    
         <INPUT TYPE = "Text"  NAME = "Time">
         <br>
         <INPUT TYPE = "Submit" Name ="Submit1" VALUE ="Login" > 
    </form>

<br>
<br>

0 个答案:

没有答案