Error setting variable inside foreach

0

I have this piece of code in PHP. When I upload to the database the images are separated by ; and the videos only ; in the last video.

foreach($html->find('img') as $imagensdescricao) {

    $imagens1 .= $imagensdescricao->src;   
    $imagens1 = mysql_real_escape_string($imagens1.";");

}

foreach($html->find('iframe') as $videodescricao) 
    $videos1  .= $videodescricao->src;
    $videos1 = mysql_real_escape_string($videos1.";");

That's how I'm sending it:

$sqlinsert="INSERT INTO eventos ( Titulo , Preco, Imagens , Datainicio , Datafim , Descricao , Local , Hora , Videos , Imagem) VALUES ( '$Titulo' ,'$preco' , '$imagens1' , '$datainicio' , '$datafim' , '$resumo' , '$local' , '$horario' , '$videos1' ,'$imagem')";
    
asked by anonymous 03.07.2015 / 18:29

1 answer

0

Well I put my errors here and I solve immediately the solution to my problem was to put {}

foreach($html->find('img') as $imagensdescricao) {

    $imagens1 .= $imagensdescricao->src;   
    $imagens1 = mysql_real_escape_string($imagens1.";");

}

foreach($html->find('iframe') as $videodescricao) {
    $videos1  .= $videodescricao->src;
    $videos1 = mysql_real_escape_string($videos1.";");}
    
03.07.2015 / 18:40