I made a simple script that inserts data into my table from an array named $videos. The result is that I get a table with correct titles but the ID is repeated over and over in all rows that were inserted. The strange thing is that when I echo $id inside the loop I get the correct id's each time. for some reason it does not insert to the table the correct id's too.
This is my code:
$page_counter = 0;
do{
$videos = $bc->find("allVideos",array("page_number" => $page_counter,"page_size" => 10, "media_delivery" => "http"));
for ($movie_counter = 0; $movie_counter < count($videos); $movie_counter++){
$name = $mysqli->escape_string($videos[$movie_counter]->name);
$id = $videos[$movie_counter]->id;
echo "ID " . $id . "<BR>";
$mysqli->query("INSERT INTO bc_current2(id,title) VALUES('$id','$name')");
}
$page_counter++;
}
while (count($videos) == 10);
So for example if each time I get printed ID's: 1 , 2 , 3 ,4 ... In my table I see the same ID : 1 repeated in each row but the title is correct and not repeated.
$movies_counter
is created within the previous block, so it doesnt exist under the last while xD.print_r($videos[$movie_counter])
orvar_dump($videos[$movie_counter])
on the place youecho
it now, and make sure to do it either for just 1 movie, or that you keep track of what is posted when. – Viridis Dec 10 '13 at 16:03