$_POST问题与数组



我在if (in_array($_POST['band', $bands] === false))上得到一个错误,我不知道为什么。我试图使一个错误数组为我的输入在我的形式。$_POST[ , ]是否需要以另一种方式格式化,或者我是否将其中一个留在表单中,只保留所选的"波段"?

错误:解析错误:语法错误、意外标记"、"、期望">

$bands = array("ACDC", "Journey", "Modest Mouse", "Band of Horses", "Vampire Weekend", "Of Monsters and Men", "Broken Bells", "Phoenix", "Fleetwood Mac", "AJR");
if (in_array($_POST['band', $bands] === false))
{$errors[] = 'Please select a band.';}

这是这个特定错误陷阱的表单下拉列表。

<input type = "text" name = "band">
<label>Band: </label>
<select name="band" size="1">
<option value = "default">Choose One</option>
<option value = "ACDC">ACDC</option>
<option value = "Journey">Journey</option>
<option value = "Modest Mouse">Modest Mouse</option>
<option value = "Band of Horses">Band of Horses</option>
<option value = "Vampire Weekend">Vampire Weekend</option>
<option value = "Of Monsters and Men">Of Monsters and Men</option>
<option value = "Broken Bells">Broken Bells</option>
<option value = "Phoenix">Phoenix</option>
<option value = "Fleetwood Mac">Fleetwood Mac</option>
<option value = "AJR">AJR</option>
</select>

Per Chris Haas(谢谢!)

应该是if (in_array($_POST['band'], $bands) === false)

相关内容

  • 没有找到相关文章

最新更新