Jump to content

foreach incomplete


brosjr

Recommended Posts

Hi everyone,

 

I wrote a script that run correctly on localhost but on server it crachs. The code is:

 

foreach($rscad as $cc=>$contashoje){

array($date = explode("-", $contashoje->vence));
$data = $date[2]."/".$date[1]."/".$date[0];

$pstnome = $conn->query("select nomeconta from tbcontas_nome where idnomeconta = $contashoje->idnomeconta");		
$rsnome = $pstnome->fetchAll( PDO::FETCH_OBJ );

$arraydatacad .= 
"<p style='line-height:120%;'>● <strong>"
.$rsnome->nomeconta
."</strong> - R$ "
.$contashoje->valor
." com vencimento em "
.$data
.";";

}

 

On localhost the script works fine and if I ask this code prints the two $rsnome result like:

 

Array ( [0] => stdClass Object ( [nomeconta] => Telefones Oi 0023, 5480 e 5482 ) )

Array ( [0] => stdClass Object ( [nomeconta] => Telefone Oi 6569 ) )

 

But on server the same script prints the second result as empty:

 

Array ( [0] => stdClass Object ( [nomeconta] => Telefones Oi 0023, 5480 e 5482 ) )

Array ( )

 

The problem happens when $rsnome has two or more values, when it holds only one value, even on server, the script works correctly.

 

Somebody  :confused:?

Thanks in advance!

Danilo Jr.

Link to comment
https://forums.phpfreaks.com/topic/244513-foreach-incomplete/
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.