Jump to content

Foreach loop


Xtremer360

Recommended Posts

For some reason I'm getting an invalid argument supplied for foreach error and I'm not sure why.

 

<?php

// Include the database page
require ('../inc/dbconfig.php');

if (isset($_POST['edit_event_lineup'])) {
    $event_items = $_POST['event_items'];
    $event_id = (int)$_POST['event_id'];
    
    foreach ($event_items as $items) { 
        print_r($items);
        $segment_writer_id = (int)$_POST['segment_writer_id'];
        $introduction = mysqli_real_escape_string($dbc, $_POST['introduction']);
        $conclusion = mysqli_real_escape_string($dbc, $_POST['conclusion']);
        $segment_type = mysqli_real_escape_string($dbc, $_POST['segment_type']);
        $match_number = (int)$_POST['match_number'];
        $segment_number = (int)$_POST['segment_number'];
        $match_type_id = (int)$_POST['match_type_id'];
        $segment_title = mysqli_real_escape_string($dbc, $_POST['segment_title']);
        $match_type_id = mysqli_real_escape_string($dbc, $_POST['match_type_id']);
        $titles_id_list = mysqli_real_escape_string($dbc, $_POST['titles_id_list']);
        $stipulations_id_list = mysqli_real_escape_string($dbc, $_POST['stipulations_id_list']);
        $characters_id_list = mysqli_real_escape_string($dbc, $_POST['character_id_list']);
        $preview = mysqli_real_escape_string($dbc, $_POST['preview']);
    }

    $query = "INSERT INTO `event_segments` 
            (event_id, segment_writer_id, segment_type, sort_order_preview, segment_title, preview, is_submitted_yes_or_no_id) 
        VALUES 
            ('".$event_id."', '".$match_writer_id."', '".$segment_type."' ,'".$sort_order_preview."','".$segment_title."','".$preview."',2)";
    mysqli_query($dbc, $query);
    
}
        
?>

Link to comment
Share on other sites

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]<br />

<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/xtremer/public_html/efedmanager/processes/bookings.php</b> on line <b>10</b><br />

 

Link to comment
Share on other sites

$_POST should never be populated with an object.

 

The only way it will be populated with an array is if you've named your files with a [] at the end, ie

 

<select name="some_name[]" multiple="multiple" size="3">

Link to comment
Share on other sites

$_POST should never be populated with an object.

 

The only way it will be populated with an array is if you've named your files with a [] at the end, ie

 

<select name="some_name[]" multiple="multiple" size="3">

 

yeah this is what confused me. I was hoping he would post the code that actually sends the post data, but instead he decided to PM the link to the page.. which didn't help at all

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.