Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/cd

I am new to php and I am trying to create a CMS for school project. I am in the data collection phase of a CMS that will run an e-commerce type business. The code below is from a php file that loads after the user selects one of 4 forms from a xhtml page. My plan for this page is to dynamically select the correct form from the xhtml page using "if and “elseif” statements and also validating form entries for each form. Presently when I run the page, I get the following error:

Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/cdlwebde/public_html/rizzo/collectionsystemrobertizzo.php on line 54

I have looked for hours for any syntax type errors but can’t figure it out. I was wondering if someone could give me some guidance and/or suggestions to fix this. Here is the php page code:

[php]

<?php if(isset($_GET["form"])) { if($_GET["form"]=="productentrysoap") { ?> <?php $soapcatalog = $_POST['soapcatalog']; $soapdescription = $_POST['soapdescription']; $soapprice = $_POST['soapprice']; $soapunits = $_POST['soapunits']; $uploadField = $_POST['uploadField']; $tried=$_POST['tried']=='yes'; if ($tried){ $validated=(!empty($soapcatalog) && !empty($soapdescription) && !empty($soapprice) && !empty($soapunits) && !empty($uploadField)); if (!$validated){ ?>

The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.

<?php if ($tried && $validated) { echo '

The item has been created.

; } ?> Soap Product Entry * Catalog:

* Soap Description:

Price:     

total number of units:       

Upload Photo:         <?php } elseif ($_GET["form"]=="productentryjewelry"{ ?> <?php $jewelrycatalog = $_POST['jewelrycatalog']; $jewelrydescription = $_POST['jewelrydescription']; $jewelryprice = $_POST['jewelryprice']; $jewelryunits = $_POST['jewelryunits']; $uploadField = $_POST['uploadField']; $tried=$_POST['tried']=='yes'; if ($tried){ $validated=(!empty($jewelrycatalog) && !empty($jewelrydescription) && !empty($jewelryprice) && !empty($jewelryunits) && !empty($uploadField)); if (!$validated){ ?>

The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.

<?php }

if ($tried && $validated) {
echo '

The item has been created.

;
}
?> Jewelry Product Entry * Catalog:

* Jewelry Description:

Price:     

total number of units:       

Upload Photo:         <?php } elseif ($_GET["form"]=="productentrycraft"{ ?> <?php $craftcatalog = $_POST['craftcatalog']; $craftdescription = $_POST['craftdescription']; $craftprice = $_POST['craftprice']; $craftunits = $_POST['craftunits]; $uploadField = $_POST['uploadField']; $tried=$_POST['tried']=='yes'; if ($tried){ $validated=(!empty($craftcatalog) && !empty($craftdescription) && !empty($craftprice) && !empty($craftunits) && !empty($uploadField)); if (!$validated){ ?>

The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.

<?php }

if ($tried && $validated) {
echo '

The item has been created.

;
}

?>

Jewelry Product Entry * Catalog:

* Jewelry Description:

Price:     

total number of units:       

Upload Photo:         <?php } else ($_GET["form"]=="nickupdates"{ ?> <?php $Nickupdate= $_POST['Nickupdate']; $uploadField = $_POST['uploadField']; $tried=$_POST['tried']=='yes'; if ($tried){ $validated=(!empty($Nickupdate) && !empty($uploadField)); if (!$validated){ ?>

The Nick update field the file upload fields need to be completed. Please complete to continue.

<?php }

if ($tried && $validated) {
echo '

The item has been created.

;
}

?>

Nick Update: Update:
Enter update here

Upload Photo:         <?php endif; }

?>

[/php]

Thank you for any assistance.

Couple of starter points:

[ol][li]Wrap your code in PHP tags, see php in the text editor.[/li]
[li]Indent your code, it’s awfully hard to read[/li]
[li]Make sure you post the entire code. The error is on line 54, but you’re missing the -> section so I no longer know what line it is.[/li][/ol]

From what I can see at first glance, is this section (note how much better it looks in PHP tags)

[PHP]
elseif ($_GET[“form”]==“productentryjewelry”{
[/PHP]

It should be:

[PHP]
elseif ($_GET[“form”]==“productentryjewelry”){
[/PHP]

Also, your markup is horrible. Input fields have no business being inside labels and all the   is just cutting corners, stick an ID on the fieldset and style your elements there. At the very least, end up with this:

[PHP]

Jewelry Product Entry * Catalog:

* Jewelry Description:

Price:

total number of units:

Upload Photo: [/PHP]

Even then, you’re abusing the
tag. The
tag is a line break within a paragraph not a content separator. It should really be in a table like this:

[PHP]

Jewelry Product Entry
* Catalog:
* Jewelry Description:
Price:
total number of units:
Upload Photo:
[/PHP]

Do you see how that last example is so much easier to read?

You are missing several curly braces. Numerous syntax errors.

Missing quote here: $craftunits = $_POST['craftunits];

You are closing PHP tags un necessarily. Line 11 and 12

If you used an IDE with code highlighting you would see the problems immediately.

**Please enclose your code posts in the php tags provided by the board so your code is more readable. I have updated your post to reflect this. You should be able to spot your errors easier now. Too many to fix for you right now.

@scottlpool2003,

input fields have no business being inside labels

This is perfectly allowable in the W3C regulations. See the specs here:
http://www.w3.org/TR/html401/interact/forms.html#h-17.9

From W3C

To associate a label with another control implicitly, the control element must be within the contents of the LABEL element. In this case, the LABEL may only contain one control element. The label itself may be positioned before or after the associated control.

In this example, we implicitly associate two labels with two text input controls:

First Name Last Name

Note that this technique cannot be used when a table is being used for layout, with the label in one cell and its associated control in another cell.
Sponsor our Newsletter | Privacy Policy | Terms of Service