I am having to update a system I built from mysql to mssql (and also from a wamp environment to IIS running windows php).
All is going well so far apart from datetime data types. I read that datetime is not supported and to use the much more forgiving datetime2 instead but I'm still getting the error
Array ( [0] => Array ( [0] => 22007 [SQLSTATE] => 22007 [1] => 241
Thanks for any suggestions
All is going well so far apart from datetime data types. I read that datetime is not supported and to use the much more forgiving datetime2 instead but I'm still getting the error
Array ( [0] => Array ( [0] => 22007 [SQLSTATE] => 22007 [1] => 241
Code:
=> 241 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string. ) )
Removing the date fields from my insert query works fine. Here's my test script
[code]
if (isset($_POST['submit'])) {
$id = $_SESSION["user_id"]
$varcharfield1 = $_POST['varcharfield1'];
$varcharfield2 = $_POST['varcharfield2'];
$datetimefield = $_POST['datetimefield'];
$params = array($varcharfield1, $varcharfield2, $datetimefield, $id);
$query = sqlsrv_query( $conn, "update mytable set
varcharfield1=?,
varcharfield2=?,
datetimefield=?
where id=?", $params);
}
Thanks for any suggestions