Answer the question
In order to leave comments, you need to log in
Why is an array passed with an index instead of a value?
Hello everyone , the task is to pass the value with the button with the Formaction attribute , I try through the name , but the controller swears that the variable came in an array , moreover, the debug shows that it came with an index . Please tell me what's wrong, thanks in advance
<td style="text-align: center;">
<a class="button">
<button id="but" name="<?= $post['post_id']; ?>" formaction="<?=$postDelete;?>" >Удалить</button>
</a>
</td>
public function postDelete() {
$this->load->model('instagram/instagram');
$post_id = $this->request->post;
d($post_id);
$this->model_instagram_instagram->postDelete($post_id);
$this->session->data['success'] = "Запись удалена!";
$this->redirect($this->url->link('instagram/instagram', 'token=' . $this->session->data['token'], 'SSL'));
}
Notice: Array to string conversion in /var/www/true-false.ru/data/www/misha.true-false.ru/admin/model/instagram/instagram.php on line 60Notice: Error: Unknown column 'Array' in 'where clause'
Error No: 1054
DELETE FROM oc_instpost WHERE post_id= Array in /var/www/true-false.ru/data/www/misha.true-false.ru/system/database/mysqliz.php on line 37
Debug:
Array
(
[1503810305041303572_1587990717] =>
)
Answer the question
In order to leave comments, you need to log in
You might need something like this:
and
// не знаю что вы за фреймворк используете, но примерно так
$post_id = $this->request->post('post_id');
// или так
$post_id = $this->request->post['post_id'];
// или даже так
$post = $this->request->post;
$post_id = $post['post_id'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question