I have an issue where my PHP sqlsrv UPDATE statement runs and doesn't return any errors but nothing in the DB ever changes and the row is not actually updated. Is there something I am missing that would allow this query to appear to run successfully but not update the row?
I have checked that the update statement runs in SQL server management studio and it updates the row.
$visitquery = "UPDATE tblVisit SET CalledInBy='WINNER' WHERE VisitID='3679061'";
$visitClose = sqlsrv_prepare($connect,$visitquery);
if( sqlsrv_execute( $visitClose))
{
echo "Statement executed.\n <br />";
}
else
{
echo "Error in executing statement.\n";
die( print_r( sqlsrv_errors(), true));
}
Thanks @JonathanAmend
sqlsrv_begin_transaction
was opened but wasn't callingsqlsrv_commit
.http://www.php.net/manual/en/function.sqlsrv-commit.php
Make sure that your script has permission to access the correct database or nothing will happen to the tables.
So first, establish a connection to the database then specify the database that contains your table.
In your setup, add this line above your code.
For each value, enclose them with quotes since they are strings.
There is more information on how to make the code here:
See this (at php.net)