0 Replies Latest reply on May 16, 2012 3:53 AM by tonybabb

    Page won't load when I do a SQL Query

    tonybabb Level 1

      I have a form where the user enters a zipcode and I'd like to do a lookup on a zipcode table so that I can store the City/ State in a hidden field that will be stored in a MySQL table when the user clicks "Submit".  When the "Submit" button is clicked it launches a javascript script shown below, I had to comment out several of the lines just to get the page to load, this ought to be easy but I can't even get the page to load without all the commented out lines below, The page that loads is here www.hollisterairshow.com/ticketwindowinfo.php , I added a line "echo 'testecho'" and that value appears in the MySQL table so I know the script is being triggered and I'm populating the hidden field with a test value. First I need to get the page to load. Can anyone suggest what am I doing wrong? Thanks for any suggestions, it must be blindingly obvious but I just can't see the problem after staring at it for hours.


      <script type="text/javascript">
      function getCitySt(){

      // Store the zip code in the location field incase it's invalid
      document.form1.location.value = document.form1.zip.value;


      document.form1.location.value = "<?php

      // Make a MySQL Connection

      $query = "SELECT zipcodes.citystate FROM zipcodes WHERE zipcodes.zipcode = document.form1.zip";
      // $result = mysql_query($query) or die(mysql_error());

      // Print out result
      // while($row = mysql_fetch_array($result)){
      //  echo $row['citystate'];
      echo 'testecho';
      // }