I am trying to to insert data from PHP form to a remote SQL Server database.
When I clicked on a button submit get an error:
Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in C:\wamp64\www\connection\connection.php on line 30
And an error: Connection could not be established. Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 5701 [code] => 5701 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed database context to 'Workflow'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed database context to 'Workflow'. ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 5703 [code] => 5703 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed language setting to us_english. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Changed language setting to us_english. ) )
I have installed ODBC driver.
Connection.php:
<?php   
$servername = "server_ip"; 
$connectionInfo=array( "Database"=>"Workflow", "UID"=>"admin", 
"PWD"=>"pass");
$conn=sqlsrv_connect($servername, $connectionInfo);
 $ID = $_POST['id'];
 $Date = $_POST['date'];
        $sql = "INSERT INTO T1 (ID,Date) VALUES ('$ID','$Date')";
 if(mysqli_query($conn,$sql)) {
    echo "Connection established.<br />";
    }else{
    echo "Connection could not be established.<br/>";
    die(print_r(sqlsrv_errors(), true));
    }
if(!mysqli_query($conn,$sql)) {
echo 'Data not inserted';
} else {
echo 'Data inserted';
}
?>
Index.html:
<!DOCTYPE html>
<html>
    <head>    
        <link rel="stylesheet" type="text/css" href="style.css">
        <title>Form</title>
    </head>
    <body>
        <form action="connection.php" method="post">
            <div class="container">
            ID: <input type="text" name="id">
                        Date: <input type="text" name="date">
            </div>
            <input type="submit" value="insert">
        </form>
    </body>
</html>
 
    