我在这段代码中遇到了麻烦,似乎无法解决问题。
我在网上查看了一下,我目前遇到的错误与一个失败的查询有关,但当我按照步骤解决这个问题时,它似乎不起作用。
我需要做的是有两个独立的列,一个用于id,另一个用于id
所保存的数据,我需要它从名为tbl typeofbusiness
的表中提取信息
这是我的代码:
<tr>
<td>Type of Business:</td>
<td>
<select name="typeofbusiness">
<option value=''> - select type of business -</option>
<?php
$sql = "SELECT tbl_typesofbusiness.ID, tbl_typesofbusiness.Agent
FROM tbl_typesofbusiness";
$res = mysqli_query($con,$sql)or ("Error: ".mysqli_error($con));
while (list($id, $tob) = mysqli_fetch_row($res)); {
echo "<option value='$id'>$tob</option>'n";
}
?>
</select>
</td>
<td>
<span class="error">*
<?php if (isset($errors['typeofbusiness']))
echo $errors['typeofbusiness']; ?>
</span>
</td>
</tr>
这将创建下拉框,并具有默认值:选择业务类型,但它似乎不会从数据库中提取数据,因为它下没有其他选项。它还显示一条错误消息。
我不知道如何通过更改或to或die来解决这个问题,但当我进行更改时,所有在或die下的代码都会出现,并且我有另外6-7个字段,这真的很不方便,更糟糕的是,当我这样做时,不会出现错误消息。
我需要有人来帮助我消除这些问题,这样它就可以从数据库中提取信息,并且不再出现所有其他错误。
错误为:
警告:mysqli_fetch_row()要求参数1为mysqli_result,布尔值在C:''wamp''www''AddLeads''addeadstemplate.php第256行调用堆栈#时间内存函数位置1 0.2188 192992{main}()中给定。。''addeadstemplate.php:0 2 2.1875 205216 mysqli_fetch_row()。。''addeadstemplate.php:256
While循环在$error变量之前关闭。
Fetch数组函数未用于$error
<?php
$errors= mysql_fetch_array($res);
?>
<td><span class="error">* <?php if (isset($errors['typeofbusiness'])) { echo$errors['typeofbusiness']; }?></span></td>
</tr>
试试这个。