gpt4 book ai didi

php 爆炸函数错误

转载 作者:行者123 更新时间:2023-11-29 09:00:03 25 4
gpt4 key购买 nike

我收到此错误消息:注意:第 18 行 C:\xampp\htdocs\evantechbd\secure\content\right_cat_pr.php 中未定义偏移量:1。我想从表中获取 news_id 和 cat_name。

这是 html 表单:

<?php
include "db.php";
$sql = mysql_query("SELECT * FROM news_cat");
?>

<form action="right_cat_pr.php" method="post" name="right_cat">
<table width="400" border="0" cellspacing="5" cellpadding="5">
<tr>
<td>News Category Name</td>
<td>
<select name="cat_name">

<?php
while($row = mysql_fetch_assoc($sql))
{
$new_id = $row['news_id'];
$cat_name = $row['cat_name'];
?>
<option "<?php echo $row['news_id'] . '|' . $row['cat_name'] ?>"><?php echo
$row['cat_name']; ?></option>
<?php
}
?>
</select>

</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="Submit" name="submit"></td>
</tr>
</table>
</form>

这是流程页面:

<?php   
include "db.php";
$row = explode('|', $_POST['cat_name']);
$news_id = $row[0]; // cat_id
$cat_name = $row[1];

$query = mysql_query("INSERT INTO right_cat VALUES ('','$news_id','$cat_name')");
if($query)
{
echo "Successfully Inserted your News Category<br/>";
}
else
{
echo "Something is wrong to Upload";
}

?>

最佳答案

您应该使用 <option value="<?php echo $row['news_id'] . '|' . $row['cat_name'] ?>" 设置选项值

关于php 爆炸函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8920827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com