尝试执行该过程时出现错误:“字段列表”中的“未知列”“数组”。我还是 php 新手,所以我想知道我的编码有什么问题。
这是首先编码。
<?php
include("dbconnect.php");
$q = mysql_query("SELECT bachok_qtt FROM bachok WHERE bachok_type = 'pants' ");
if(is_resource($q) and mysql_num_rows($q)>0)
{
$r = mysql_fetch_array($q);
$r["bachok_qtt"];
}
$w = mysql_query("SELECT bachok_qtt FROM bachok WHERE bachok_type = 'clothes' ");
if(is_resource($w) and mysql_num_rows($w)>0)
{
$s = mysql_fetch_array($w);
$s["bachok_qtt"];
}
$e = mysql_query("SELECT stock_qtt FROM stock WHERE stock_type = 'pants' ");
if(is_resource($e) and mysql_num_rows($e)>0)
{
$a = mysql_fetch_array($e);
$a["stock_qtt"];
}
$t = mysql_query("SELECT stock_qtt FROM stock WHERE stock_type = 'clothes' ");
if(is_resource($t) and mysql_num_rows($t)>0)
{
$b = mysql_fetch_array($t);
$b["stock_qtt"];
}
if ($r < $a)
{
if($s < $b)
{
$sql1 = "UPDATE stock SET stock_qtt = stock_qtt - $r WHERE stock_type = 'pants' ";
$sql2 = "UPDATE stock SET stock_qtt = stock_qtt - $s WHERE stock_type = 'clothes' ";
$result1 = mysql_query($sql1) or die ("Error: " . mysql_error());
$result2 = mysql_query($sql2) or die ("Error: " . mysql_error());
if($result1)
{
if($result2)
{
echo "Successful";
echo "<br>";
echo "<a href='admin2.php'>Back to main page</a>";
}
}
else
{
echo "ERROR";
}
}
}
else
{
echo "Not enough stock";
echo "<br>";
echo "<a href='admin2.php'>Back to main page</a>";
}
?>
那么,为什么它在执行时会抛出未知的列数组。我是否正确使用了 MySQL_fetch_array()?