Page 2 of 2

Re: help with shop cart

Posted: Thu Feb 19, 2015 10:21 pm
by Christopher
Follow the variables back.

5. $valuetota is from $valuetotal.

4. $valuetotal is from $value.

3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].

2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).

1. $_POST['code'] gets set if there is a form with a field with name="code".

So check the values of the variables starting with the value of $_POST['code'].

Re: help with shop cart

Posted: Fri Feb 20, 2015 10:04 am
by tsalmeida
Celauran wrote:$valuetota is just a formatted version of $valuetotal which, in turn, is coming from $value set in your switch statement. So, as I asked earlier, have you confirmed that $value is getting set? Have you confirmed that the queries in your switch statement actually work?
Christopher wrote:Follow the variables back.

5. $valuetota is from $valuetotal.

4. $valuetotal is from $value.

3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].

2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).

1. $_POST['code'] gets set if there is a form with a field with name="code".

So check the values of the variables starting with the value of $_POST['code'].


The variable is correctly returning the values in the table html, my problem would only be time to insert in the database

i have this project in a online server...u can check on line if u want.

if u want follow this:
-go to http://www.meucaixa.tk/
-click on the image
-username:teste
password:teste
-click "VENDER"
-in the search field type "8237-207 Branco"
-click "COMPRAR" in one of the results

now is the shop cart

-in the column "A Vista/Parcelado" select one of the options in the combo box (this combo box is the switch
-in the column "Preço" shows the variable $forma and $value both from switch
-in the column "Total" shows the variable $valuetotal from switch too

when click in the button "finalizar venda" runs the queries...and the query with this variable variable shows zero

as i said, i put this variable on script alert.

Re: help with shop cart

Posted: Fri Feb 20, 2015 5:31 pm
by Christopher
For each step I listed, did you echo the values of the variables I showed above? Please show us the values in each step.

Re: help with shop cart

Posted: Sat Feb 21, 2015 9:22 am
by tsalmeida
Christopher wrote:For each step I listed, did you echo the values of the variables I showed above? Please show us the values in each step.
Yes...i did

I will use the example I gave q as a reference to your question

1. $_POST['code'] gets set if there is a form with a field with name="code".
$_POST ['code'] = 1 or 2 or 3

2. $value only gets set if $_POST['code'] is 1, 2 or 3 (the default is commented out).
3. $value is from $resu6['precovenda'] or $resu7['precotres'] or $resu8['precoseis'].
$value if $_POST['code'] = 1 $value = 70,00 ->$resu6['precovenda']
$value if $_POST['code'] = 2 $value = 24,00 ->$resu7['precotres']
$value if $_POST['code'] = 3 $value = 13,00 ->$resu8['precoseis']

4. $valuetotal is from $value.

$valuetotal if $_POST['code'] = 1 $value = 70,00 ->$resu6['precovenda'] * 1
$valuetotal if $_POST['code'] = 2 $value = 24,00 ->$resu7['precotres'] * 3
$valuetotal if $_POST['code'] = 3 $value = 13,00 ->$resu8['precoseis'] * 6


5. $valuetota is from $valuetotal.

$valuetota and $valuetotal = $resu6['precovenda'] * 1 = 70,00
$valuetota and $valuetotal = $resu7['precotres'] * 3 = 72,00
$valuetota and $valuetotal = $resu8['precoseis'] * 6 = 78,00


the variables is correctly

just in time to save in db shows the value zero

Re: help with shop cart

Posted: Sat Feb 21, 2015 3:11 pm
by Christopher
if you try to manually do the insert with the value '78,00' what value do you get in valorunitario? Do you get an error?

e.g, INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('1','2','3','78,00',NOW())

Is the problem that your database is configured for '.' for the decimal place, and not ',' ?

Re: help with shop cart

Posted: Sun Feb 22, 2015 12:16 pm
by tsalmeida
Christopher wrote:if you try to manually do the insert with the value '78,00' what value do you get in valorunitario? Do you get an error?

e.g, INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('1','2','3','78,00',NOW())

Is the problem that your database is configured for '.' for the decimal place, and not ',' ?
insert manually ok

Image

Re: help with shop cart

Posted: Sun Feb 22, 2015 2:50 pm
by Christopher
tsalmeida wrote:insert manually ok
I assume you mean there are no errors and the value is not 0. Correct? (you did not show the value, so we don't know).

If the value is correct, then is the SQL for the INSERT exactly the same if you do:

Code: Select all

       echo "INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())<br>";
        $sqlinsereitens = mysql_query("INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())")or die(mysql_error());

Re: help with shop cart

Posted: Tue Feb 24, 2015 10:03 am
by tsalmeida
Christopher wrote:
tsalmeida wrote:insert manually ok
I assume you mean there are no errors and the value is not 0. Correct? (you did not show the value, so we don't know).

If the value is correct, then is the SQL for the INSERT exactly the same if you do:

Code: Select all

       echo "INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())<br>";
        $sqlinsereitens = mysql_query("INSERT into itenspedido(idpedido,idproduto,quantidadeitens,valorunitario,data) VALUES('$idvenda','$idproduto','$qtd','$valuetota',NOW())")or die(mysql_error());
Hi Christopher,

I did two ways to understand ... before clicking the button "FINALIZAR VENDA" the result of insert was this image

Image

after clicking the "FINALIZAR VENDA", the result is that

Image

Re: help with shop cart

Posted: Mon Mar 02, 2015 12:18 pm
by tsalmeida
help!!!

Re: help with shop cart

Posted: Thu Mar 05, 2015 3:52 pm
by tsalmeida
:( :( :( :( :( :( :( :(

Re: help with shop cart

Posted: Fri Mar 06, 2015 2:38 pm
by Christopher
I am really not clear how to help at this point. You get to your shopping cart and you have a value. Then you submit again from the shopping cart to the shopping cart -- and the value is zero. You need to check step-by-step to see where the value is not being passed or being set to zero.