Forum Moderators: coopster

Message Too Old, No Replies

parse error

unexpected $ last line

         

firemaster

10:42 pm on Oct 9, 2005 (gmt 0)

10+ Year Member



okay I wasn't able to fix this code so I decided to merge the pages into one for the the form. here it is:

<?php
if ($_POST['Submit']!= "") {
$errormess = "";
$p1 = $_POST['phone_1'];
$p2 = $_POST['phone_2'];
$p3 = $_POST['phone_3'];
$phone = $p1."-".$p2."-".$p3;
if (empty($_POST['name'])) $errormess .= "Item Name<br>";
if (empty($_POST['description'])) $errormess .= "Item Description<br>";
if (empty($_FILES['imgfile'])) $errormess .= "Image File<br>";
if (empty($_POST['price'])) $errormess .= "Item Price<br>";
if (empty($phone)) $errormess .= "Phone Number<br>";
if ($errormess!= "")
{
echo "<b>You did not fill out the following:</b><br>",$errormess;
$formerror = "yes";
}
if ($formerror!= "yes") {
include("class_form_d.php");
}
} // problem starts below this line I think ------------
if ($formerror == "yes") {
if ($_POST['name']!= "") { $itemname = $_POST['name']; }
if ($_POST['description']!= "") { $description = $_POST['description'];}
if ($_FILES['imgfile']!= "") { $imgfile = $_FILES['imgfile']; }
if ($_POST['price']!= "") { $price = $_POST['price']; }
if ($_POST['phone_1']!= "") {
$p1 = $_POST['phone_1'];
$p2 = $_POST['phone_2'];
$p3 = $_POST['phone_3'];
}
print "
<form name=\"class_form_1\" method=\"post\" action=\"class_all.php?a=5\" enctype=\"multipart/form-data\">
<div align=\"center\">
<table width=\"30%\" height=\"78\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"box\">
<tr>
<td width=\"28%\" height=\"13\">Item Name:</td>
<td width=\"72%\"><input name=\"name\" type=\"text\" maxlength=\"45\" value=".$itemname."></td>
</tr>
<tr>
<td height=\"13\" valign=\"top\">Item Description:</td>
<td><textarea name=\"description\" cols=\"50\" rows=\"4\" value=".$description."></textarea></td>
</tr>
<tr>
<td height=\"13\">Image:</td>
<td><input name=\"imgfile\" type=\"file\" id=\"imgfile\" value=".$imgfile."></td>
</tr>
<tr>
<td height=\"13\">Price:</td>
<td>\$
<input name=\"price\" type=\"text\" id=\"price\" maxlength=\"14\" value=".$price."></td>
</tr>
<tr>
<td height=\"13\">Phone Number:</td>
<td>1-
(
<input name=\"phone_1\" type=\"text\" id=\"phone_1\" size=\"3\" maxlength=\"3\" value=".$p1.">)
-
<input name=\"phone_2\" type=\"text\" id=\"phone_2\" size=\"3\" maxlength=\"3\" value=".$p2.">-
<input name=\"phone_3\" type=\"text\" id=\"phone_3\" size=\"4\" maxlength=\"4\" value=".$p2."></td>
</tr>
<tr>
<td height=\"13\">&nbsp;</td>
<td><input name=\"Submit\" type=\"submit\" id=\"Submit\" value=\"Submit\"> </td>
</tr>
</table>
</div>
</form>";
exit;
}
if ($_POST['Submit'] == "") {
print'
<form name="class_form_1" method="post" action="class_all.php?a=5" enctype="multipart/form-data">
<div align="center">
<table width="30%" height="78" border="0" cellpadding="0" cellspacing="0" class="box">
<tr>
<td width="28%" height="13">Item Name:</td>
<td width="72%"><input name="name" type="text" maxlength="45"></td>
</tr>
<tr>
<td height="13" valign="top">Item Description:</td>
<td><textarea name="description" cols="50" rows="4"></textarea></td>
</tr>
<tr>
<td height="13">Image:</td>
<td><input name="imgfile" type="file" id="imgfile"></td>
</tr>
<tr>
<td height="13">Price:</td>
<td>\$
<input name="price" type="text" id="price" maxlength="14"></td>
</tr>
<tr>
<td height="13">Phone Number:</td>
<td>1-
(
<input name="phone_1" type="text" id="phone_1" size="3" maxlength="3">)
-
<input name="phone_2" type="text" id="phone_2" size="3" maxlength="3">-
<input name="phone_3" type="text" id="phone_3" size="4" maxlength="4"></td>
</tr>
<tr>
<td height="13"></td>
<td><input name="Submit" type="submit" id="Submit" value="Submit"> </td>
</tr>
</table>
</div>
</form>';?>

I have been changing all kind of things and cannot find the problem. Thanks
-Mike

rich_b

6:59 am on Oct 10, 2005 (gmt 0)

10+ Year Member



You have:

if ($_POST['Submit'] == "") {

...with an opening curly brace but you do not have a corresponding closing curly brace at the bottom of the file. You need something like this:

</form>'; }?>

I haven't tested it but hope it works for you.

firemaster

9:44 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



good call.. I was looking at them guess it was over looked in the couple variations of this script, thanks,
-Mike