身份不明的常数并假定为

时间:2014-08-06 17:27:50

标签: php html forms

我对此代码有问题,即使用echo中的值ID。例如。

echo "<label for='prod_brand'>Product Brand:</label><br />
      <input name='prod_brand' id='prod_brand' type='text' maxlength='150' class='col1' placeholder='Auto Complete Form' value='$prodbrand'/>
      <div class='clear'></div>";

我这样做时会出错,我该如何解决?我需要查询表单中的结果,以便我可以编辑它。

while ($row=mysql_fetch_array($result)){
     $prodbrand    = $row[prod_brand];
     $prodname     = $row[prod_name];
     $prodcategory = $row[prod_category];
     $prodprice    = $row[prod_price];
     $proddesc     = $row[prod_desc];
     $prodpic      = $row[prod_pic];
     $prodquantity = $row[prod_quantity];

2 个答案:

答案 0 :(得分:0)

您的数组键周围缺少引号:

$prodbrand = $row['prod_brand'];
$prodname = $row['prod_name'];
$prodcategory = $row['prod_category'];
$prodprice = $row['prod_price'];
$proddesc = $row['prod_desc'];
$prodpic = $row['prod_pic'];
$prodquantity = $row['prod_quantity'];

答案 1 :(得分:0)

数组访问键是字符串:

$row["prod_brand"]

而不是:

$row[prod_brand]