PDA

View Full Version : Getting undefined variable.. why?



FlashDance
Oct 12th, 2011, 10:39 AM
I'm getting:


PHP Notice: Undefined variable: carttotal

... for this:


$idtotal = $sizestotal + $sizemtotal + $sizeltotal + $sizexltotal;
$carttotal += $idtotal;


Why?

FlashDance
Oct 12th, 2011, 10:46 AM
$carttotal = +$idtotal;

EDIT: While this stopped the PHP notice, it made my calculation thing stop working.

tangoforce
Oct 12th, 2011, 11:19 AM
At the top of your code do this:
$carttotal = 0;

Otherwise when you use += it expects there to be a value to add to - and there isn't if its null is there.

FlashDance
Oct 12th, 2011, 11:39 AM
tangoforce, your talent impresses me every time!

FlashDance
Oct 12th, 2011, 11:43 AM
If my website takes off how I imagine it will, expect high-end clothing coming your way of your choice, free of charge.

Its too bad this there isn't a coding forum where there is a "tip" concept setup, so you can tip someone to their PayPal account or something to say thank you.
A cool concept I've had on my mind for the past month, but I know I will never get around to making it.

tangoforce
Oct 12th, 2011, 12:07 PM
Heh.. I should add a paypal link to my sig :D

FlashDance
Oct 12th, 2011, 12:27 PM
So do it man!