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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.