Bind Param不工作有什么不对?

I am executing a Stored Procedure on another server. I want to be able to pass my paramaters/variables to that Stored Procedure. However, my code stops short of that as it fails on the bindParam part.

I have looked at bindParam online and at different examples. I have tried may different things and variations but nothing seems to work. I assume it must be a syntax error someplace but code checks out in editor.

try {


    $conn = new PDO("sqlsrv:Server=$server;Database=$database", $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));

    if($conn){

    echo "Connection is good.... <br />";
    $sql = 'CALL web.WebImportWoRequestDirect (:WebREQUESTEDBY, :WebSTARTDATE, :WebFINISHDATE, :WebTASKDESC, :WebSITEID, :WebLOCATION, :WebPRIORITY, :WebESTDURATION, :WebPHONE, :WebEXT, :WebTEXTS)';

    echo "Stored Procedure has been called....<br />";

    // prepare for execution of the stored procedure
    $stmt = $conn->prepare($sql);
    echo "Preparing SQL Statement... <br />";

    // pass value to the command
    $stmt->bindParam(':WebREQUESTEDBY', 'WEBUSER00001', PDO::PARAM_STR);
    $stmt->bindParam(':WebSTARTDATE', '06-28-2019', PDO::PARAM_STR);
    $stmt->bindParam(':WebFINISHDATE',  '06-29-2019', PDO::PARAM_STR);
    $stmt->bindParam(':WebTASKDESC',  'Title Here...', PDO::PARAM_STR);
    $stmt->bindParam(':WebSITEID',  'UMONCTON', PDO::PARAM_STR);
    $stmt->bindParam(':WebLOCATION',  'Some Place', PDO::PARAM_STR);
    $stmt->bindParam(':WebPRIORITY',  '2', PDO::PARAM_NUM);
    $stmt->bindParam(':WebESTDURATION',  '', PDO::PARAM_NUM);
    $stmt->bindParam(':WebPHONE',  '555-555-5555', PDO::PARAM_STR);
    $stmt->bindParam(':WebEXT', 'MCH1', PDO::PARAM_STR);
    $stmt->bindParam(':WebTEXTS',  'Massive text here...', PDO::PARAM_LOB);

    echo "CHECK - pass value to the command...<br />";

    //Execute the stored procedure...
    $stmt->execute();

    echo "Executed Stored Procedure....<br />";

    #$conn = null;
    }
    echo "Well... ask Gif if it worked...";

} catch (PDOException $e) {
            echo "There is some problem in connection: <br />" . $e->getMessage();
}

What I want is to be able to pass the variables to the stored procedure...

Problem 1

The method bindParam requires a variable as the second parameter. You are using strings.

If you don't want to use variable you should use the bindValue method instead.

So it's either:

$stmt->bindValue(':WebREQUESTEDBY', 'WEBUSER00001', PDO::PARAM_STR);

or

$webuser = 'WEBUSER00001';
$stmt->bindParam(':WebREQUESTEDBY', $webuser, PDO::PARAM_STR);

Problem 2

PDO::PARAM_NUM is not a valid constant. Use PDO::PARAM_INT instead.