title: Javascript/JQuery - Chrome unexpected token
body: <p>Am following a web developer course on-line and one of the projects is to create a fictional stock trading site.</p>
  
  <p>I am using jQuery and the Validator plugin on my lookup page, but when I load it in Chrome, I keep getting Uncaught SyntaxError: Unexpected token messages, sometimes for ":", other times its "&lt;".</p>
  
  <p>I have looked through similar entries on the site, and tried displaying all chars and checked for matching brackets and braces (notepad++) to no avail, and have gone through the code again and again to no avail before asking for help.</p>
  
  <p>The page code is below. I would really appreciate any pointers. Hopefully I haven't missed anything silly but ...</p>
  
  <pre><code>    &lt;?
      require("../includes/common.php");
      $userID = $_SESSION['id'];
  
      $userQuery = $dsn-&gt;prepare("SELECT balance FROM cs75f_users WHERE uid=:uidQ");
      $userQuery-&gt;bindParam(":uidQ",$userID);
      $userQuery-&gt;execute();
      $userData = $userQuery-&gt;fetch();
      $userBalance = $userData[0];
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="javascript/jquery-1.7.2.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="javascript/jquery.validate.js"&gt;&lt;/script&gt;
  &lt;style type="text/css"&gt;
  * { font-family: Verdana; font-size: 96%; }
  label { width: 10em; float: left; }
  label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
  p { clear: both; }
  .submit { margin-left: 12em; }
  em { font-weight: bold; padding-right: 1em; vertical-align: top; }
  &lt;/style&gt;
  &lt;script type="text/javascript"&gt;&lt;![CDATA[
  
  $(document).ready(function()
  {
      $("#search").select();
      $("#infoDiv").slideUp();
      $("#buyDiv").slideUp();
  
      var searchVal = $("#searchForm").validate({
          rules:{
              search:{
                  required:true,
                  minlength:4,
                  maxlength:4
              },
          },
          messages:{
              search:{
                  required:"Please enter a valid stock symbol",
                  minlength:"Please enter a valid 4 character stock symbol",
                  maxlength:"Please enter a valid 4 character stock symbol"
              },
          },
          errorPlacement: function(error,element)
          {
              if (element.is(":radio"))
              {
                  error.appendTo(element.parent().next().next() );
              }
              else if (element.is(":checkbox"))
              {
                  error.appendTo(element.next() );
              }
              else
              {
                  error.appendTo(element.parent().next() );
              }
          }
      });
  
      $("#searchForm").submit(function() {
          $.ajax({
              url:"getquote.php",
              data:{
                  symbol:$("#search").val()
                    }
              success: function(data) {
                  $("#name").html(data.name);
                  $("#price").html(data.price);
                  $("#high").html(data.high);
                  $("#low").html(data.low);
                  $("#infoDiv").slideDown();
                  $("#buyDiv").slideDown();
                  $("#qty").select();
                  $("#hSymbol").val(data.symbol);
              }
          });
          return false;
      });
  
      var buyVal = $("#buyForm").validate({
          rules:{
              qty:{
                  required:true,
                  min:1,
                  max:10000,
                  digits:true
              },
          },
          messages:{
              qty:{
                  required:"Please enter a valid quantity",
                  min:"You must purchase at least one share",
                  max:"Upper limit of 10,000 shares at one time",
                  digits:"Please enter a valid number"
              },
          },
          errorPlacement:function(error,element) {
              if (element.is(":radio"))
              {
                  error.appendTo(element.parent().next().next() );
              }
              else if (element.is(":checkbox"))
              {
                  error.appendTo(element.next() );
              }
              else
              {
                  error.appendTo(element.parent().next() );
              }
          }
  
      });
  });
  
  ]]&gt;&lt;/script&gt;
  
  &lt;title&gt;CS75 Finance Login&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="logo" align="center"&gt;
      &lt;img src="images/logo.gif" border="0" alt="CS75 Finance" /&gt;
  &lt;/div&gt;
  &lt;div id="welcome" align="center"&gt;
      &lt;h4&gt;Welcome to CS75 Finance&lt;/h4&gt;
      &lt;h4&gt;Stock Information Quote&lt;/h4&gt;
  &lt;/div&gt;
  
  &lt;div id="searchDiv" align="center"&gt;
      &lt;form id="searchForm"&gt;
          &lt;table border="0" cellspacing="2" cellpadding="2"&gt;
              &lt;tr&gt;
                  &lt;td&gt;Symbol:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" id="search" size="10" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" value="Search" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;div id="infoDiv" align="center"&gt;
      &lt;h4&gt;Selected stock details:&lt;/h4&gt;
      Company: &lt;span id="name"&gt;&lt;/span&gt;&lt;br /&gt;
      Price: $&lt;span id="price"&gt;&lt;/span&gt;&lt;br /&gt;
      High: $&lt;span id="high"&gt;&lt;/span&gt;&lt;br /&gt;
      Low: $&lt;span id="low"&gt;&lt;/span&gt;&lt;br /&gt;
  &lt;/div&gt;
  
  &lt;br /&gt;
  
  &lt;div id="buyDiv" align="center"&gt;
      &lt;form id="buyForm" method="post" action="buy.php"&gt;
          &lt;table border="0" cellspacing="2" cellpadding="2"&gt;
              &lt;tr&gt;
                  &lt;td colspan="5" align="center"&gt;&lt;b&gt;Your current balance is: $&lt;/b&gt;&lt;? echo number_format($userBalance,2); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="hidden" id="hSymbol" /&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;Qty:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" id="qty" name="qty" size="10" value="1" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" value="Purchase" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;?
      $dsn = NULL;
  ?&gt;
  
  &lt;br /&gt;
  &lt;hr width="70%"&gt;
  &lt;p align="center"&gt;CS75 Finance. Copyright 2012. All right reserved.&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Hope I posted correctly. Thanks in advance.</p>