so i have this form. I simply want to take all the fields and assign them to a variable for use later, but for some reason I keep getting a parse issue..Parse error: syntax error, unexpected $end on line 422

<?php
$Fname = $_POST["firmname"];
if (!isset($_POST['submit'])) {
?>

<html>
<head>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">
</script> 



</style>
</head>
<body bgcolor="#002E2F">
<center>
<form method="post" action="<?php echo $PHP_SELF;?>"> 

<table border="0" bordercolor="#000000" style="background-color:#FFFFFF" width="663" cellpadding="3" cellspacing="3">
	<tr style="background-color: #f4fbee">
		<td width="324"><font face="verdana" size="2">Firm Name</font></td>

	<td width="324"><br /><input type="text" name="firmname" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Firm Contact Name</font></td>
	<td width="324"><input type="text" name="firmcontactname" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Title</font></td>
	<td width="324"><input type="text" name="title" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Phone Number</font></td>
	<td width="324"><input type="text" name="phonenumber" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Fax Number</font></td>
	<td width="324"><input type="text" name="faxnumber" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Email Address</font></td>
	<td width="324"><input type="text" name="email" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Website</font></td>
	<td width="324"><input type="text" name="website" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Street Address</font></td>
	<td width="324"><input type="text" name="street" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">City</font></td>
	<td width="324"><input type="text" name="city" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">State</font></td>
	<td width="324"><input type="text" name="state" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Country</font></td>
	<td width="324"><input type="text" name="country" size="50" /></td>
</tr>
<tr style="background-color: #f4fbee">
	<td width="324"><font face="verdana" size="2">Postal Code</font></td>
	<td width="324"><input type="text" name="postal" size="50" /></td>
</tr>
</table>
<table border="0" style="background-color:#f4fbee" width="651" height="25" cellpadding="3" cellspacing="3">
	<tr>
		<td><hr /></td>
	</tr>

</table>
</form>
</center>
</body>
</html>

<?
} else {
echo "Hello, ".$Fname." ";
}
?>

can anyone tell me what I'm doing wrong? please note this is a shortened version of my full form, kinda exceeded the max characters by about 7,000 when i posted the full thing... thanks for your help.

    Welcome to PHPBuilder!

    Few issues I see with the code snippet you posted...

    1. I highly suggest you stick to using the full "<?php" tags rather than relying on the "<?" short tags being enabled. For example, since I personally disable the short_tags directive on all of my servers, I got an "unexpected $end" parse error with your code above until I modified the one "<?" tag.

    2. Once I did fix the above error, note that there are no parse errors in the code snippet you posted above... thus there's not much we can do to help you with any errors you're getting with the actual code. Since PHP error messages include line numbers, is there any reason why you couldn't just post the few lines at and above (so we can see the context) the line # indicated?

    3. Note that there is no need to duplicate the data in another variable just to use it; $POST['firmname'] works just as well as $Fname, in other words.

    4. This type of code:

      $Fname = $_POST["firmname"]; 

      is going to generate E_NOTICE level errors if the external variable wasn't actually set (e.g. if no data was POST'ed or the POST data didn't contain that field). Instead, you should first check to see if that external variable actually exists, e.g. using [man]isset/man or [man]empty/man.

      At the very least, I never reference external POST'ed variables without first checking to see if some specific form element was POST'ed (e.g. a submit button). More often, however, if I really need to duplicate POST'ed data in another variable, I'll use the ternary operator like so:

      $Fname = isset($_POST['firmname']) ? $_POST['firmname'] : NULL;
    5. <?php echo $PHP_SELF;?>

      Where do you ever define $PHP_SELF ?

      Thanks for your reply! I am going to just upload the form.php page since it can work independently at the moment. The overall goal of this form is to submit everything to a database. I figured it would be easier to store all the form fields into variables that way when I insert it into the database it would be easy enough to just use the variable names that have already been defined.

        Write a Reply...