【发布时间】:2022-01-20 05:49:08
【问题描述】:
我尝试通过使用 odbc_fetch_array 来获取价值并将它们转换为变量,但是当我尝试回显时,它只是说“arrayarrayarray”
Array (
[0] => Array ( [PKDSEQ] => 154604 )
[1] => Array ( [PKDSEQ] => 154604 )
[2] => Array ( [PKDSEQ] => 154529 )
[3] => Array ( [PKDSEQ] => 161689 )
[4] => Array ( [PKDSEQ] => 158940 )
[5] => Array ( [PKDSEQ] => 155383 )
[6] => Array ( [PKDSEQ] => 156247 )
[7] => Array ( [PKDSEQ] => 158123 )
)
有没有办法将数组分成数字?
代码
$PKDSEQ2 = array();
$table4 = "SELECT [PKDSEQ] FROM [PWSWMS].[dbo].[tbTR_PACKD] WHERE [PKDSEQ] = '$PKDSEQRS5'";
$RS4 = odbc_exec($connection2, $table4);
while ($PKDSEQ2 = odbc_fetch_array($RS4)) {
$PKDSEQ[] = $PKDSEQ2;
}
}
print_r(array_values($PKDSEQ));
if(isset($_POST['QTYINPUT1'])) {
$QTYINPUT1 = $_POST['QTYINPUT1'];
$update = "UPDATE [PWSWMS].[dbo].[tbTR_PACKD] SET QTYPCK='$QTYINPUT1' WHERE [PKDSEQ]='$PKDSEQ[1]'";
$result = odbc_exec($connection2, $update);
echo "<br>$QTYINPUT1";
echo "<br>$PKDSEQ[1]";
}
【问题讨论】:
-
您的代码容易受到 SQL 注入攻击。您应该使用参数化查询和准备好的语句来帮助防止攻击者通过使用恶意输入值来破坏您的数据库。 bobby-tables.com 解释了风险。请参阅stackoverflow.com/questions/5756369/…,了解如何在 PHP 中将预准备语句与 ODBC 一起使用。