我的脚本锁定就像这个例子。
$variable1 = $POST['field1'];
$variable2 = $POST['field2'];
$variable3 = $POST['field3'];
$sql11 = "UPDATE ....
.......$variable1.............
$sql12 = "UPDATE ....
.......$variable1.............
$sql13 = "UPDATE ....
.......$variable1.............
$sql21 = "UPDATE ....
.......$variable2.............
$sql22 = "UPDATE ....
.......$variable2.............
$sql23 = "UPDATE ....
.......$variable2.............
$sql31 = "UPDATE ....
.......$variable3.............
$sql32 = "UPDATE ....
.......$variable3.............
$sql33 = "UPDATE ....
.......$variable3.............
sqlsrv_query($conn, sql11);
sqlsrv_query($conn, sql12);
sqlsrv_query($conn, sql13);
sqlsrv_query($conn, sql21);
sqlsrv_query($conn, sql22);
sqlsrv_query($conn, sql23);
sqlsrv_query($conn, sql31);
sqlsrv_query($conn, sql32);
sqlsrv_query($conn, sql33);
header ("Location: http:file.php");
有时最后的查询没有受到影响。为什么?问题可能是因为脚本太长了?和文件在完成写入之前被重定向到file.php?所有更新语句都是正确的。怎么解决?对于循环是个好主意?