Does anyone have example php for webhooks to MSSQL?

  • Profile Image
    Asked on June 26, 2017 at 03:54 PM

    Hi, I have tried to get data from webhooks to my Azure database using php, but with no luck.


    Now I have just managed to solve it with using mysql instead and with help from all the examples on this forum.

    But still I want to make this in Azure and with MSSQL.

    Can someone please share examples of php for communicate and send webhooks data to a MSSQL database?


    Thanks for any hints or tips :)




  • Profile Image
    Answered on June 26, 2017 at 04:12 PM

    You can find some webhook php examples here:

    Webhook PHP Script Examples 

    (#3. specifically allows you to send your form data to a MySQL database).

  • Profile Image
    Answered on June 26, 2017 at 04:24 PM

    Thanks aubreybourke, these was one of the examples that helped me understanding the communication to mysql.

    But I need examples of php scripts that can be used to MSSQL.

    So far I have managed to connect to the MSSQL database successfully, and I can query it.


    So I just need help with defining and sending data (I think).




  • Profile Image
    Answered on June 26, 2017 at 06:26 PM

    We do not have examples with MSSQL. We only have with MySQL: 

  • Profile Image
    Answered on June 26, 2017 at 06:37 PM

    Ok, thanks!


    Desperate attempt on a php script, the connection is working.

    $conn = sqlsrv_connect($serverName, $connectionOptions);


    $fieldvalues = $_REQUEST['rawRequest'];

    $obj = json_decode($fieldvalues, true);

    $sid = $conn->real_escape_string($_REQUEST['submissionID']);

    $MekaniskAnsatt = $conn->real_escape_string($obj['q5_mekaniskAnsatt']);

    $ElektroAnsatt = $conn->real_escape_string($obj['q102_elektroAnsatt102']);


    $insertSql = "INSERT INTO Timeføring (SubmissionID, MekaniskAnsatt, ElektroAnsatt) 

    VALUES (?,?,?)";

    $params = array(&$_POST['$sid'], 



    $stmt = sqlsrv_query($conn, $insertSql, $params);





  • Profile Image
    Answered on June 26, 2017 at 09:03 PM

    Hello McQuinge,

    Thank you for sharing the code with us. We'll gladly take note of this.

    I see that you are using the SQLSRV driver of the PHP Microsoft Drivers for SQL Server. The difference between MSSQL and MySQL when coding with PHP are function names on connecting to its database. Since the usage of PHP is more common with Linux and MySQL databases (and as this combination is most common on web hosting service providers), the guide that we have set to provide is for PHP and MySQL, with also the assumption that the account owner has already setup his PHP with MySQL properly.

    But it's not completely different when calling database functions. This may also further help you on coding PHP with MSSQL via SQLSRV:

    Here is also a list of functions available on PHP's website: 

    If you have questions or if you still have hurdles on this matter, please let us know.