Jump to content

Recommended Posts

I did var_dump at the $_POST and it has returned :

 

array(2) { ["idProduto"]=>  string(1) "2" ["produtos"]=>  array(1) { [0]=>  string(1) "1" } }

 

 

after i did this

foreach($_POST['produtos'] AS $key=>$value){
    $adicionaProdutoQuery = "INSERT INTO Proposta_Produto_Temporario(IDPropostaTemporaria,IDProduto)
							 VALUES($idProposta,$value)"; 

//echo $adicionaProdutoQuery . "<br />";
					$database->execute($adicionaProdutoQuery);	


}

The funniest thing here, is that if i use the echo, it just prints one time, but if i use the $database->execute() , it inserts the query twice. I really don't understand :x

 

Any ideas ?

 

 

That will be impossible. If your output inside the foreach is only one time, meaning the block code inside the foreach will only executed one time.

 

Try use constant string for output like:

echo "a";

inside the foreach to make sure is only running one time.

 

Beside, please check your database class's function, 'execute'.

That will be impossible. If your output inside the foreach is only one time, meaning the block code inside the foreach will only executed one time.

 

Try use constant string for output like:

echo "a";

inside the foreach to make sure is only running one time.

 

Beside, please check your database class's function, 'execute'.

 

I said the same, it's impossible, but it's happening !! I changed $database->execute to mysql_query() and it's the same, it inserts the query twice and i tried using echo constant string has you said and it just returned one time.

 

The stupid thing now it's that i have this

 

foreach($_POST['produtos'] AS $key=>$value){

 

 

$adicionaProdutoQuery = "INSERT INTO Proposta_Produto_Temporario(IDPropostaTemporaria,IDProduto)

VALUES($idProposta,$value)"; 

 

//echo $adicionaProdutoQuery . "<br />";

//$database->execute($adicionaProdutoQuery);

mysql_query($adicionaProdutoQuery);

echo "a";

 

}

 

and it's executing the query 2 times but i just see a single "a" character.

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.