Page 1 of 1

Parse error: parse error, unexpected T_IF warning:long post

Posted: Mon May 01, 2006 1:27 pm
by ZoidbergJunky
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello, I am new to PHP and I am trying to develop a function that will gain an estimate for vistors through a form, I have the form all worked out, and I have written the PHP code to process it.  When I went to test it out, I got this error messege:

Code: Select all

Parse error: parse error, unexpected T_IF
The block of code it pointed to is as follows


Code: Select all

if ($quantity2 < "3000"){
$reloadprice = 0;}

if ($quantity2 > "3000"){
if ($printsides == "one"){
$reloadprice = $quantity2 / 3000 * 20;}}

if ($quantity2 > "3000"){
if ($printsides == "two"){
$reloadprice = $quantity2 / 3000 * 40;}}


if ($quantity2 <= "6000"){
$impressionprice = 0;}

if ($quantity2 > "6000"){
if ($printsides == "one"){
$impressionprice = $quantity2 / 6000 * 60;}}

if ($quantity2 > "6000"){
if ($printsides = "two"){
$impressionprice = $quantity2 / 6000 * 120;}}

$price1 + $price2 + $impressionprice + $reloadprice = $total;

echo $total;
I have checked the syntax, and to the best of my knowledge it is all correct, also I have used similar code on another page on the same server without any errors

Can anyone here help me out? As I said I am new to PHP and I would apprieciate any help at all

the full code is as follows

Code: Select all

<?php



//set varibles from form

$colorchoice = $_POST['colorchoice'];
$design = $_POST['design'];
$printsides = $_POST['printsides'];
$quantity = $_POST['quantity'];
$paper = $_POST['paper'];
$closereg = $_POST['closereg'];

//set color info from form
//deal with those checkboxes
foreach($_POST['colors'] as $value) { 
$f .= $value; 
} 
    

//begin estimate process

//get color price

if ($colorchoice == "one"){
$colorprice = 60;}

if ($colorchoice == "two"){
$colorprice = 120;}

if ($colorchoice == "three"){
$colorprice = 180;}

//get close registration price

if ($closereg == "two"){
$closeregprice = 0;}


if ($closereg == "one"){
if ($colorchoice == "one"){
$closeregprice = 0;}}

if ($closereg == "one"){
if ($colorchoice == "two"){
$closeregprice = 30;}}

if ($closereg == "one"){
if ($colorchoice == "three"){
$closeregprice = 60;}}

//get printsides 
  
if ($printsides == "one"){
$printsides2 = 1;}

if ($printsides == "two"){
$printsides2 = 2;}

//get quantity

$quantity == $quantity2;

if ($quantity < "100"){
$quantity2 = 100;}

//get paper price

//8 and 1/2 x 11
if ($paper == "one"){
$paperprice = .01;}

if ($paper == "two"){
$paperprice = .02;}

if ($paper == "three"){
$paperprice = .04;}

if ($paper == "four"){
$paperprice = .03;}

if ($paper == "five"){
$paperprice = .07;}

if ($paper == "six"){
$paperprice = .03;}

if ($paper == "seven"){
$paperprice = .03;}

if ($paper == "eight"){
$paperprice = .08;}

if ($paper == "nine"){
$paperprice = .04;}

if ($paper == "ten"){
$paperprice = .05;}

if ($paper == "oneone"){
$paperprice = .10;}

if ($paper == "onetwo"){
$paperprice == .11;}

if ($paper == "onethree"){
$paperprice = .05;}

if ($paper == "onefour"){
$paperprice = .06;}

//8 and 1/2 by 14 (legal size)

if ($paper == "onefive"){
$paperprice = .01;}

if ($paper == "onesix"){
$paperprice = .03;}

if ($paper == "oneseven"){
$paperprice = .05;}

if ($paper == "oneeight"){
$paperprice = .045;}

if ($paper == "onenine"){
$paperprice = .04;}

//11 x 17 (ledger)

if ($paper == "twofour"){
$paperprice = .02;}

if ($paper == "twofive"){
$paperprice = .04;}

if ($paper == "twosix"){
$paperprice = .06;}

if ($paper == "twoseven"){
$paperprice = .06;}

if ($paper == "twoeight"){
$paperprice = .13;}

if ($paper == "twonine"){
$paperprice = .05;}

if ($paper == "threezero"){
$paperprice = .07;}

if ($paper == "threeone"){
$paperprice = .14;}

if ($paper == "threetwo"){
$paperprice = .14;}

if ($paper == "threethree"){
$paperprice = .10;}

if ($paper == "threefour"){
$paperprice = .20;}


if ($paper == "threefive"){
$paperprice = .25;}

if ($paper == "threesix"){
$paperprice = .10;}

if ($paper == "threeseven"){
$paperprice = .09;}

//begin get total price

$colorprice + $closeregprice = $price1;

$quantity2 * $paperprice = $price2

if ($quantity2 < "3000"){
$reloadprice = 0;}

if ($quantity2 > "3000"){
if ($printsides == "one"){
$reloadprice = $quantity2 / 3000 * 20;}}

if ($quantity2 > "3000"){
if ($printsides == "two"){
$reloadprice = $quantity2 / 3000 * 40;}}


if ($quantity2 <= "6000"){
$impressionprice = 0;}

if ($quantity2 > "6000"){
if ($printsides == "one"){
$impressionprice = $quantity2 / 6000 * 60;}}

if ($quantity2 > "6000"){
if ($printsides = "two"){
$impressionprice = $quantity2 / 6000 * 120;}}

$price1 + $price2 + $impressionprice + $reloadprice = $total;

echo $total;


?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon May 01, 2006 1:56 pm
by Nathaniel
Dunno mate, couldn't catch it. But you probably want to change if ( $printsides = "two" ) to if ( $printsides == "two" )

Also, putting every { and } on its own line, as well as indenting, could make such bugs easier to find...

- Nathaniel

Posted: Mon May 01, 2006 2:19 pm
by ZoidbergJunky
Thanks for the response I do need to work on better code structure

anyone see what the problem is?

I've problay looked over this 100 times now and I can't figure it out

Posted: Mon May 01, 2006 2:32 pm
by ambivalent

Code: Select all

$quantity2 * $paperprice = $price2 //missing a semi-colon here

Posted: Mon May 01, 2006 2:43 pm
by ZoidbergJunky
Thank you so much ambivalent

I can't believe I missed that!

It works now, thanks everyone for your help.

Does anyone know of a good place where I can learn more about php?

Posted: Mon May 01, 2006 3:49 pm
by Nathaniel
Yes, right here. :)

Posted: Mon May 01, 2006 4:00 pm
by ambivalent
ZoidbergJunky wrote:
Does anyone know of a good place where I can learn more about php?
http://www.hudzilla.org/phpbook/