2
are trying to enter in the database information of multiple checkbox at once , for example a news is related to more than one category then and only select the categories and save , however this giving this error ,
Notice: Array to string conversion in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 19
ErroArray ( [0] => HY000 [1] => 1366 [2] => Incorrect integer value: 'Array' for column 'carteira_id' at row 1 )
Notice: Undefined variable: idlogado in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 32
Notice: Array to string conversion in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 19
ErroArray ( [0] => HY000 [1] => 1366 [2] => Incorrect integer value: 'Array' for column 'carteira_id' at row 1 )
Notice: Undefined variable: idlogado in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 32
Notice: Array to string conversion in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 19
ErroArray ( [0] => HY000 [1] => 1366 [2] => Incorrect integer value: 'Array' for column 'carteira_id' at row 1 )
Notice: Undefined variable: idlogado in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 32
Notice: Array to string conversion in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 19
ErroArray ( [0] => HY000 [1] => 1366 [2] => Incorrect integer value: 'Array' for column 'carteira_id' at row 1 )
Notice: Undefined variable: idlogado in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 32
Notice: Array to string conversion in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 19
ErroArray ( [0] => HY000 [1] => 1366 [2] => Incorrect integer value: 'Array' for column 'carteira_id' at row 1 )
Notice: Undefined variable: idlogado in C:\Program Files\VertrigoServ\www\painel\pg\cadamsg.php on line 32
several errors appeared because there are all checkbox selected there is the code
<?php
foreach ($carteira as $cart) {
echo '
<div class="checkbox i-checks">
<label>
<input type="checkbox" name="f_carteira[]" value="'.$cart['id'].'">
<i></i>
'.$cart["nome"].'
</label>
</div> ' ;
}
?>
Insert
<?php
session_start();
include '../config/config.inc.php';
error_reporting(E_ALL);
if (isset($_POST["submit"])) {
$carteira = $_POST['f_carteira'];
if($carteira){
foreach ($carteira as $car) {
$cadastrarmensagem = $pdo->prepare("INSERT INTO mensagem(codigo,conteudomsg,categoria_id,carteira_id,usuario_id) VALUES(:codigo,:conteudo,:categoria,:carteira,:usuarioid)");
$cadastrarmensagem->bindValue(":codigo",$_POST["f_codigo"]);
$cadastrarmensagem->bindValue(":conteudo",$_POST["f_msg"]);
$cadastrarmensagem->bindValue(":categoria",$_POST["f_cat"]);
$cadastrarmensagem->bindValue(":carteira",$_POST["f_carteira"]);
$cadastrarmensagem->bindValue(":usuarioid",$_POST["f_usuario"]);
$cadastrarmensagem->execute();
$linha = $cadastrarmensagem->rowCount();
if($linha > 0){
echo "Mensagem Cadastrada com Sucesso";
header ("Location: ../index.php?pg=mensagens");
}else {
echo "Erro";
//imprimindo erro da variavel de consulta
print_r($cadastrarmensagem->errorInfo());
echo "$idlogado";
}
}
}
}else{echo "aconteceu algum erro";}
?>
hello friend , could inform me how I would create a new table ?
– Thalles Honorato