brosjr Posted August 11, 2011 Share Posted August 11, 2011 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 ? Thanks in advance! Danilo Jr. Link to comment https://forums.phpfreaks.com/topic/244513-foreach-incomplete/ Share on other sites More sharing options...
brosjr Posted August 11, 2011 Author Share Posted August 11, 2011 Sorry, the problem occurs when $rscad hold more than one value, not $rsnome. It's like the foreach could only execute once. Link to comment https://forums.phpfreaks.com/topic/244513-foreach-incomplete/#findComment-1255957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.