Parse error: syntax error, unexpected T_STRING, expecting ',

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
rjizzo
Rank 0 - Newcomer
Posts: 5
Joined: Thu Apr 10, 2014 1:33 pm

Parse error: syntax error, unexpected T_STRING, expecting ',

Post by rjizzo »

Hello - My name is Rob and I am new to PHP. I am presently working on a school project of creating a CMS for a craft business that will require 4 separate forms and the forms will also require validation. I feel that I have a grasp on the basics of PHP, but the syntax is confusing me. Below is the code on my PHP page (the starting page is an XHTML page that has a dropdown menu to select which form to use). I was wondering if someone could assist me with the syntax. I keep getting the following error also when I run the code:

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

I also welcome any critiques or suggestions also. Here is the code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Robert Izzo's Final Project</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="http://cdlwebsysdev.esc-atsystems.net/rizzo/externalcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?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){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
if ($tried && $validated) {
echo '<p>The item has been created.</p>;
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/soapprocessing.php" method="post">
<fieldset id="soapproduct_entry"><legend>Soap Product Entry</legend>
<table>
<tr>
<td><label for="soapcatalog">  Catalog: </label><input type="text" name="soapcatalog" id="soapcatalog" /></td>
</tr>
<tr>
<td><label for="soapdescription">  Soap Description: </label><input type="text" name="soapdescription" id="soapdescription" /></td>
</tr>
<tr>
<td><label for="soapprice">Price: </label><input type="text" name="soapprice" id="soapprice" /></td>
</tr>
<tr>
<td><label for="soapunits">total number of units: </label><input type="text" name="soapunits" id="soapunits" /></td>
</tr>
</table>
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset"/> 
</fieldset>
</form>
<?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){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
}

if ($tried && $validated) {
echo '<p>The item has been created.</p>;
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/jewelryprocessing.php" method="post">
<fieldset id="jewelryproduct_entry"><legend>Jewelry Product Entry</legend>
<table>
<tr>
<td><label for="jewelrycatalog"> * Catalog: </label><input type="text" name="jewelrycatalog" id="jewelrycatalog" /></td>
</tr>
<tr>
<td><label for="jewelrydescription"> * Jewelry Description: </label><input type="text" name="jewelrydescription" id="jewelrydescription" /></td>
</tr>
<tr>
<td><label for="jewelryprice">Price: </label><input type="text" name="jewelryprice" id="jewelryprice" /></td>
</tr>
<tr>
<td><label for="jewelryunits">total number of units: </label><input type="text" name="jewelryunits" id="jewelryunits" /></td>
</tr>
</table>
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset"/> 
</fieldset>
</form>

<?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){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
}

if ($tried && $validated) {
echo '<p>The item has been created.</p>;
}

?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/craftprocessing.php" method="post">
<fieldset id="craftproduct_entry"><legend>Craft Product Entry</legend>
<table>
<tr>
<td><label for="craftcatalog">  Catalog: </label><input type="text" name="craftcatalog" id="craftcatalog" /></td>
</tr>
<tr>
<td><label for="craftdescription"> * Jewelry Description: </label><input type="text" name="craftdescription" id="craftdescription" /></td>
</tr>
<tr>
<td><label for="craftprice">Price: </label><input type="text" name="craftprice" id="craftprice" /></td>
</tr>
<tr>
<td><label for="craftunits">total number of units: </label><input type="text" name="craftunits" id="craftunits" /></td>
</tr>
</table>
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset"/> 
</fieldset>
</form>

<?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){
?>
<p>
The Nick update field the file upload fields need to be completed. Please complete to continue.
</p>
<?php
}

if ($tried && $validated) {
echo '<p>The item has been created.</p>;
}

?>

 <form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/nickupdates.php" method="post">
 <fieldset><legend>Nick Update:</legend>
 <label> Update:<br />
 <textarea name="Nickupdate" id="Nickupdate" cols="40" rows="2">Enter update here</textarea>
 </label><br /><br />
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset" />
 </fieldset>
 </form>
<?php
}
}

?>

</body>
</html>
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Parse error: syntax error, unexpected T_STRING, expectin

Post by Albert Wiersch »

Hello,

I checked this in CSE HTML Validator using the PHP syntax checker. It was a little 'tricky' to find but it's caused by a missing single quote before the semicolon in line 31.

This is the corrected line:

Code: Select all

echo '<p>The item has been created.</p>';
There's a similar syntax error in line 77 and 124

I hope this helps.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
rjizzo
Rank 0 - Newcomer
Posts: 5
Joined: Thu Apr 10, 2014 1:33 pm

Re: Parse error: syntax error, unexpected T_STRING, expectin

Post by rjizzo »

Thanks for that catch. I corrected that. but now get another error:

Parse error: syntax error, unexpected $end in /home/cdlwebde/public_html/rizzo/collectionsystemrobertizzo.php on line 193

What I don't understand is that there is no code written on line 193.
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Parse error: syntax error, unexpected T_STRING, expectin

Post by Albert Wiersch »

I can't reproduce that. Can you post the latest code?
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
rjizzo
Rank 0 - Newcomer
Posts: 5
Joined: Thu Apr 10, 2014 1:33 pm

Re: Parse error: syntax error, unexpected T_STRING, expectin

Post by rjizzo »

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Robert Izzo's Final Project</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="http://cdlwebsysdev.esc-atsystems.net/rizzo/externalcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?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){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
if ($tried && $validated) {
echo 'The item has been created.';
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/soapprocessing.php" method="post">
<fieldset id="soapproduct_entry"><legend>Soap Product Entry</legend>
<table>
<tr>
<td><label for="soapcatalog">  Catalog: </label><input type="text" name="soapcatalog" id="soapcatalog" /></td>
</tr>
<tr>
<td><label for="soapdescription">  Soap Description: </label><input type="text" name="soapdescription" id="soapdescription" /></td>
</tr>
<tr>
<td><label for="soapprice">Price: </label><input type="text" name="soapprice" id="soapprice" /></td>
</tr>
<tr>
<td><label for="soapunits">total number of units: </label><input type="text" name="soapunits" id="soapunits" /></td>
</tr>
</table>
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset"/> 
</fieldset>
</form>
<?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){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
}

if ($tried && $validated) {
echo 'The item has been created.';
}
?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/jewelryprocessing.php" method="post">
<fieldset id="jewelryproduct_entry"><legend>Jewelry Product Entry</legend>
<table>
<tr>
<td><label for="jewelrycatalog"> * Catalog: </label><input type="text" name="jewelrycatalog" id="jewelrycatalog" /></td>
</tr>
<tr>
<td><label for="jewelrydescription"> * Jewelry Description: </label><input type="text" name="jewelrydescription" id="jewelrydescription" /></td>
</tr>
<tr>
<td><label for="jewelryprice">Price: </label><input type="text" name="jewelryprice" id="jewelryprice" /></td>
</tr>
<tr>
<td><label for="jewelryunits">total number of units: </label><input type="text" name="jewelryunits" id="jewelryunits" /></td>
</tr>
</table>
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset"/> 
</fieldset>
</form>

<?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){
?>
<p>
The catalog number, description, price, units and upload fields need to be completed. Please complete to continue.
</p>
<?php
}

if ($tried && $validated) {
echo 'The item has been created.';
}

?>
<form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/craftprocessing.php" method="post">
<fieldset id="craftproduct_entry"><legend>Craft Product Entry</legend>
<table>
<tr>
<td><label for="craftcatalog">  Catalog: </label><input type="text" name="craftcatalog" id="craftcatalog" /></td>
</tr>
<tr>
<td><label for="craftdescription"> * Jewelry Description: </label><input type="text" name="craftdescription" id="craftdescription" /></td>
</tr>
<tr>
<td><label for="craftprice">Price: </label><input type="text" name="craftprice" id="craftprice" /></td>
</tr>
<tr>
<td><label for="craftunits">total number of units: </label><input type="text" name="craftunits" id="craftunits" /></td>
</tr>
</table>
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset"/> 
</fieldset>
</form>

<?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){
?>
<p>
The Nick update field the file upload fields need to be completed. Please complete to continue.
</p>
<?php


if ($tried && $validated) {
echo "The item has been created.";
}

?>
 <form action="http://cdlwebsysdev.esc-atsystems.net/rizzo/nickupdates.php" method="post">
 <fieldset><legend>Nick Update:</legend>
 <label> Update:<br />
 <textarea name="Nickupdate" id="Nickupdate" cols="40" rows="2">Enter update here</textarea>
 </label><br /><br />
 <label>Upload Photo:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="file" name="uploadField" />
 </label>
 <input type="submit" value="click to submit" />&nbsp;<input type="reset" />
 </fieldset>
 </form>
<?php
}
}
?>
</body>
</html>







User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Parse error: syntax error, unexpected T_STRING, expectin

Post by Albert Wiersch »

Looks like the code is missing a couple of closing (right) curly brackets ('}'). I added a couple on line 188 and it fixed the syntax problem but you may want to check your if/elseif/else structure to make sure it's correct.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply