gpt4 book ai didi

PHP 内爆(): Invalid arguments passed

转载 作者:行者123 更新时间:2023-12-03 15:25:25 26 4
gpt4 key购买 nike

我有一个 php 表单,它有一个复选框选项,如果用户选择“其他”,则会出现一个文本输入。这运行良好,但未提交数据。我收到错误消息 PHP implode():传递的参数无效

这是:

PHP验证

if(!isset($_POST['competitor_model'])){   
echo '<p><font color="red" size="+1">• Please select at least one competitor model</font></p>';
} else {
$compmodel = implode(',', $_POST['competitor_model']);
}

这是 JS/HTML 表单
        <script type="text/javascript">
var temp = '';
function disableTxt() {
var field = document.getElementById("other");
if(field.value != '') {
temp = field.value;
}
field.style.display = "none";
field.value = '';
}
function enableTxt() {
document.getElementById("other").style.display = "inline";
document.getElementById("other").value = temp;
}
</script>


<input type="checkbox" value="BMW 3-series" onchange="disableTxt()" name='competitor_model[]'>BMW 3-series<br>
<input type="checkbox" value="Mercedes Benz C-class" onchange="disableTxt()" name='competitor_model[]'>Mercedes Benz C-class<br>
<input type="checkbox" value="Lexus IS" onchange="disableTxt()" name='competitor_model[]'>Lexus IS<br>
<input type="checkbox" value="Audi A4" onchange="disableTxt()" name='competitor_model[]'>Audi A4<br>
<input type="checkbox" value="Other" onchange="enableTxt(Number)" name='competitor_model[]'>Other <em>If yes please submit model</em>
<input type="text" name="competitor_model[]" id="other" style="display:none;" value="<?php if (isset($_POST['competitor_model'])) echo $_POST['competitor_model']; ?>"/>

最佳答案

$_POST['competitor_model']是一个数组。试试这个:

if (is_array($_POST['competitor_model']))
{
$compmodel = implode(",", $_POST['competitor_model']);
}

或者试试这样-
echo implode(', ', (array)$_POST['competitor_model']);

PHP implode()

关于PHP 内爆(): Invalid arguments passed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33601881/

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