Syntax error: unexpected '!'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Morgan
    New Member
    • Oct 2011
    • 41

    #16
    All spaces removed. Now getting this Error coding on the site: We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.

    The RAID you entered do not appear to be valid.
    The Extras you entered do not appear to be valid.
    The Accessories you entered do not appear to be valid.
    The Customer Specifics you entered do not appear to be valid.
    The Maximum Budget you entered do not appear to be valid.


    Please go back and fix these errors.


    The respective coding for each of the above are:
    Code:
    !isset($_POST['raid']) ||
    
    $RAID = $_POST['raid']; 
    
      if(strlen($RAID) < 2) {
        $error_message .= 'The RAID you entered do not appear to be valid.<br />';   
      }
    
    $email_message .= "RAID: ".clean_string($raid)."\n";
    Code:
    !isset($_POST['extras']) ||
    
    $Optional_Extras = $_POST['extras']; 
    
    if(strlen($Optional_Extras) < 2) {
        $error_message .= 'The Extras you entered do not appear to be valid.<br />';
      }
    
    $email_message .= "Optional Extras: ".clean_string($extras)."\n";
    Code:
    !isset($_POST['accessories']) ||
    
    $Accessory_Packs = $_POST['accessories'];
    
    if(strlen($Accessory_Packs [2]) < 2) {
        $error_message .= 'The Accessories you entered do not appear to be valid.<br />';   
      }
    
    $email_message .= "Accessory Packs [2]: ".clean_string($accessories)."\n";
    Code:
    !isset($_POST['customer']) ||
    
    $Customer_Specifics = $_POST['customer'];
    
    if(strlen($Customer_Specifics) < 2) {
        $error_message .= 'The Customer Specifics you entered do not appear to be valid.<br />';   
      }
    
    $email_message .= "Customer Specifics: ".clean_string($customer)."\n";
    Code:
    !isset($_POST['budget'])) ||
    
    $Maximum_Budget = $_POST['budget']; 
    
    if(strlen($Maximum_Budget) < 2) {
        $error_message .= 'The Maximum Budget you entered do not appear to be valid.<br />';   
      }
    
    $email_message .= "Maximum Budget: ".clean_string($budget)."\n";
    The names on the HTML are the same as on the PHP so I think it's something I'm just failing to see.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #17
      That depends on what's being passed to the PHP page and whether or not they meet the validation you set.

      Comment

      • Matt Morgan
        New Member
        • Oct 2011
        • 41

        #18
        This is the HTML code which makes up the form.
        Code:
        <form name="customform" method="post" action="CustomForm.php">
        				<table width="350" align="center" id="customform">
        				</tr>
        				<tr>
         				<td align="left" valign="top">
          				<label for="first_name">First Name </label> 				</td>
         				<td align="left" valign="top">
          				<input  type="text" name="first_name" maxlength="50" size="30"></td>
        				</tr>
         
        				<tr>
         				<td align="left" valign="top"">
          				<label for="last_name">Last Name </label> 				</td>
         				<td align="left" valign="top">
          				<input  type="text" name="last_name" maxlength="50" size="30"></td>
        		</tr>
        				<tr>
        				<td align="left" valign="top">
          				<label for="email">Email Address </label> 				</td>
         				<td align="left" valign="top">
          				<input  type="text" name="email" maxlength="80" size="30"></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="role">Role </label> 				</td>
         				<td align="left" valign="top">
          				
        			      <select name="role">
        			        <option value="Choose"> </option>
        			        <option value="Home">Home</option>
        			        <option value="Home/ Office">Home/ Office</option>
        			        <option value="Home/ Gaming">Home/ Gaming      </option>
        			        <option value="Core Gaming">Core Gaming</option>
        			        <option value="Unsure">Unsure[1]</option>
        		          </select></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="ram">Memory Size</label> 				</td>
         				<td align="left" valign="top">
          				<select name="ram">
        				<option value="Choose"> </option>
        				<option value="2GB">2GB</option>
        				<option value="4GB">4GB</option>
        				<option value="8GB">8GB</option>
        				<option value="16GB">16GB</option>
        				<option value="customer">Other (Please Specify)</option>
        				<option value="role">Role Specific</option>
        				</select></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="raid">RAID</label> 				</td>
         				<td align="left" valign="top">
          				<select name="raid">
        				<option value="Choose"> </option>
        				<option value="Y">Yes*</option>
        				<option value="N">No</option>
        				</select>
          				<span class="style8">(*Requires 2 identical Hard Drives)</span></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="hdd1">Hard Drive 1 </label> 				</td>
         				<td align="left1" valign="top">
          				<select name="hdd1">
        				<option value="Choose"> </option>
        				<option value="250GB">250GB</option>
        				<option value="320GB">320GB</option>
        				<option value="500GB">500GB</option>
        				<option value="750GB">750GB</option>
        				<option value="1TB">1TB</option>
        				<option value="1.5TB">1.5TB</option>
        				<option value="2TB">2TB</option>
        				<option value="role">Role Specific</option>
        				</select></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="hdd2">Hard Drive 2 </label> 				</td>
         				<td align="left" valign="top">
          				<select name="hdd2">
        				<option value="Choose"> </option>
        				<option value="250GB">250GB</option>
        				<option value="320GB">320GB</option>
        				<option value="500GB">500GB</option>
        				<option value="750GB">750GB</option>
        				<option value="1TB">1TB</option>
        				<option value="1.5TB">1.5TB</option>
        				<option value="2TB">2TB</option>
        				<option value="role">Role Specific</option>
        				</select></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="os">Operating System </label> 				</td>
         				<td align="left" valign="top">
          				<select name="os">
        				<option value="Choose"> </option>
        				<option value="WinXP">Windows XP</option>
        				<option value="Win7">Windows 7</option>
        				<option value="None">None</option>
        				</select></td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="gpu">Graphics Card </label> 				</td>
         				<td align="left" valign="top">
          				<select name="gpu">
        				<option value="Choose"> </option>
        				<option value="512MB">512MB</option>
        				<option value="1GB">1GB</option>
        				<option value="1.5GB">1.5GB</option>
        				<option value="2GB">2GB</option>
        				<option value="3GB">3GB</option>
        				<option value="3D">nVidia 3D [Pack 5]</option>
        				<option value="role">Role Specific</option>
        				<option value="None">None (Chipset)</option>
        				</select>
          				[All nVidia] </td>
        				</tr>
        				
        				<tr>
        				<td height="146" align="left" valign="top">
          				<label for="extras">Optional Extras </label> 				</td>
        				<td align="left" valign="top">
        			      <input type="checkbox" name="Extras" value="TV"/> 
        			      TV Card <br />
        			      <input type="checkbox" name="Extras" value="Sound" /> 
        			      Sound Card  <br />
        			      <input name="Extras" type="checkbox" value="Disk" /> 
        			      Disk Drive <br />
        			      <input name="Extras" type="checkbox" value="WiFi" /> 
        			      WiFi  Connectivity <br />
        				  <input type="checkbox" name="Extras" value="Bluetooth" /> 
        			      Bluetooth <br />
        				  <input type="checkbox" name="Extras" value="S.B.D." /> 
        			      Seperate Boot Drive <br />
        			      <input type="checkbox" name="Extras" value="MemCard" /> 
        			      Memory Card Reader </td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="accessories">Accessory Packs [2]</label> 				</td>
        				<td align="left" valign="top">
        			     <input name="accessories" type="checkbox" value="None" checked="checked"/> 
        			      None <br />
        			      <input type="checkbox" name="accessories" value="1" /> 
        			      Pack 1  <br />
        			      <input type="checkbox" name="accessories" value="2" /> 
        			      Pack 2 <br />
        			      <input type="checkbox" name="accessories" value="3" /> 
        			      Pack 3 <br />
        				  <input type="checkbox" name="accessories" value="4" /> 
        			      Pack 4 <br />
        				  <input type="checkbox" name="accessories" value="5" /> 
        			      Pack 5 <br />
        				  <input type="checkbox" name="accessories" value="6" /> 
        			      Pack 6 <br />
        			      <input type="checkbox" name="accessories" value="Other" /> 
        			      Other (Please Specify) <br />			      </select>			      </td>
        				</tr>
        				
        				<tr>
        				<td align="left" valign="top">
          				<label for="guarantee">Guarantee </label> 				</td>
         				<td align="left" valign="top">
          				<select name="guarantee">
        				<option value=" "> </option>
        				<option value="No Yr">No Extension</option>
        				<option value="1 Yr">1 Year Extension</option>
        				<option value="2 Yr">2 Year Extension</option>
        				</select></td>
        				</tr>
        				
        				<tr>
         				 <td align="left" valign="center">
        				  <label for="customer">Customer Specifics </label>				</td>
         				<td align="left" valign="top">
          				  <textarea name="comments" cols="25" rows="6">Enter any options you selected as 'Other'. Also add any extras that you'd like and are not listed above.</textarea></td>
        				</tr>
        				
        				<tr>
         				 <td align="left" valign="center">
        				  <label for="budget">Maximum Budget </label>				</td>
         				<td align="left" valign="top">
          				  <input name="comments" type="text" value="£ Max." size="25" maxlength="50" /></td>
        				</tr>
        				
        				<tr>
         				<td colspan="2" style="text-align:center">
          				<input type="submit" value="Request Quote"></td>
        				</tr>
        				</table>

        Comment

        • zorgi
          Recognized Expert Contributor
          • Mar 2008
          • 431

          #19
          You have this in yor HTML:

          Code:
          <select name="raid">
          <option value="Choose"> </option>
          <option value="Y">Yes*</option>
          <option value="N">No</option>
          </select>
          And than in your php you have:

          Code:
          $RAID = $_POST['raid'];  
            if(strlen($RAID) < 2) {
              $error_message .= 'The RAID you entered do not appear to be valid.<br />';   
            }
           
          $email_message .= "RAID: ".clean_string($raid)."\n";
          This can only be valid for <option value="Choose"> </option>
          .

          Comment

          • zorgi
            Recognized Expert Contributor
            • Mar 2008
            • 431

            #20
            Also be careful with capital letters. In your HTML you have:

            Code:
            <input type="checkbox" name="[B]E[/B]xtras" value="TV"/>
            and in your php

            Code:
            $Optional_Extras = $_POST['[B]e[/B]xtras'];
            Extras != extras

            Comment

            • zorgi
              Recognized Expert Contributor
              • Mar 2008
              • 431

              #21
              Inconsistencies like two I described are repeating.

              Comment

              • Matt Morgan
                New Member
                • Oct 2011
                • 41

                #22
                Thought I had it fixed, but still have the error messages for RAID, Accessories and Guarantee.

                RAID
                Code:
                !isset($_POST['raid']) ||
                
                $RAID = $_POST['raid'];
                
                if(strlen($RAID) < 2) {
                    $error_message .= 'The RAID you entered do not appear to be valid.<br />';   
                  }
                
                $email_message3 .= "RAID: ".clean_string($RAID)."\n";
                
                <tr>
                				<td align="left" valign="top">
                  				<label for="raid">RAID </label> 				</td>
                 				<td align="left" valign="top">
                			      <select name="raid">
                			        <option value="raid"> </option>
                			        <option value="Y">Yes*</option>
                			        <option value="N">No</option>
                		          </select>
                  				<span class="style8">(*Requires 2 identical Hard Drives)</span></td>
                				</tr>
                Accessories
                Code:
                !isset($_POST['accessories']) ||
                
                $Accessory_Packs = $_POST['accessories'];
                
                if(strlen($Accessory_Packs) < 2) {
                    $error_message .= 'The Accessories you entered do not appear to be valid.<br />';   
                  }
                
                $email_message9 .= "Accessory Packs: ".clean_string($Accessory_Packs)."\n";
                
                <tr>
                				<td align="left" valign="top">
                  				<label for="accessories">Accessory Packs [2]</label> 				</td>
                				<td align="left" valign="top">
                			     <input type="checkbox" name="accessories" value="0" checked="checked"/> 
                			      None <br />
                			      <input type="checkbox" name="accessories" value="1" /> 
                			      Pack 1  <br />
                			      <input type="checkbox" name="accessories" value="2" /> 
                			      Pack 2 <br />
                			      <input type="checkbox" name="accessories" value="3" /> 
                			      Pack 3 <br />
                				  <input type="checkbox" name="accessories" value="4" /> 
                			      Pack 4 <br />
                				  <input type="checkbox" name="accessories" value="5" /> 
                			      Pack 5 <br />
                				  <input type="checkbox" name="accessories" value="6" /> 
                			      Pack 6 <br />
                			      <input type="checkbox" name="accessories" value="Other" /> 
                			      Other (Please Specify) <br />			      </select>			      </td>
                				</tr>
                Guarantee
                Code:
                !isset($_POST['guarantee']) ||
                
                $Guarantee = $_POST['guarantee'];
                
                if(strlen($Guarantee) < 2) {
                    $error_message .= 'The Guarantee you entered do not appear to be valid.<br />';
                  }
                
                $email_message10 .= "Guarantee: ".clean_string($Guarantee)."\n";
                
                <tr>
                				<td align="left" valign="top">
                  				<label for="guarantee">Guarantee </label> 				</td>
                 				<td align="left" valign="top">
                  				<select name="guarantee">
                				<option value="guarantee"> </option>
                				<option value="0">No Extension</option>
                				<option value="1">1 Year Extension</option>
                				<option value="2">2 Year Extension</option>
                				</select></td>
                				</tr>
                Think I'm missing something here, but just can't seem to get it to work.

                Comment

                • zorgi
                  Recognized Expert Contributor
                  • Mar 2008
                  • 431

                  #23
                  I think you missed that link I gave you before:



                  strlen("1") is 1 and 1 < 2
                  strlen("2") is 1 and 1 < 2
                  strlen("Y") is 1 and 1 < 2

                  Comment

                  • Matt Morgan
                    New Member
                    • Oct 2011
                    • 41

                    #24
                    How do I get around this then? I don't understand what the link shows in respect to the errors in my PHP.

                    Comment

                    Working...