I've built my first PHP site and I'm interacting with an SQL database.The code is supposed to insert a record into a table. The code does complete the insert, but throws 3 warning messages. I do not know how to remove the messages. I tried to suppress the warnings in the php.ini by turning off error reporting, but that did not stop the warnings. I read that it's better to fix the errors rather than suppress them, but I know not how to do that.
PHP Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\Parishes_prod\administration\add_location.php on line 49
PHP Warning: sqlsrv_free_stmt() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\Parishes_prod\administration\add_location.php on line 50
PHP Warning: sqlsrv_close() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\Parishes_prod\administration\add_location.php on line 51
41. $tsql = "insert into tbllocation (event_ID, Date, Location ) values(?,?,?)";
42. $dt = $_POST['date'];
43. if ($dt == ""){
44. $dt = null;
45. }
46. $params = array($_POST['eventID'], $dt, $_POST['location']);
47. $serverName = "localhost";
48. $connectionInfo = array( "Database"=>"database", "UID"=>"User", "PWD"=>"password" );
49. $conn = sqlsrv_connect( $serverName, $connectionInfo);
50. $stmt = sqlsrv_query($conn, $tsql, $params);
51. sqlsrv_free_stmt($stmt);