Why the mysql update query in php not working?
<p>Please help me regarding the problem specified in the title.</p>

<p>Input form page code:</p>

<pre><code>  &lt;?
   db_connect();
  $query1 = "SELECT *, DATE_FORMAT(eventdate,'%m/%d/%y') AS 
   eventdate,DATE_FORMAT(throughdate,'%m/%d/%y') AS throughdate FROM events WHERE id = "     . mysql_real_escape_string($_REQUEST['id']);
  $result1 = mysql_query($query1) or die("Error - query failed " . mysql_error()); 

  if ( mysql_num_rows($result1) == 0 ) {
  print "&lt;p&gt;Error - no such event.&lt;/p&gt;\n";
  return;
  }
 else {

 $qry_event1 = mysql_fetch_array($result1); 

  }

// default the formaction to the query
 if (! isset($_REQUEST['formaction']) ) { $_REQUEST['formaction'] = 'query'; }

?&gt;
 &lt;form name="eventform" method="post" action="act_updevent.php"&gt;
 &lt;input type="hidden" name="submit_check" value="1"&gt;
 &lt;input type="hidden" name="formaction" value="form"&gt;
  &lt;!-- if we are editing, $id will exist.  Pass it along. --&gt;
 &lt;input type="hidden" name="id" value="&lt;?php $qry_event1['id'];?&gt;"&gt;
 &lt;table&gt;
 &lt;tr&gt;
 &lt;td align="right" valign="center"&gt;&lt;b&gt;&lt;? displayformlabel('eventdate','Event Date:')?&gt;  
  &lt;/b&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="eventdate" value="&lt;? echo  $qry_event1['eventdate']; ?&gt;"&gt;
  &lt;a name="calendar1here" id="calendar1here" href="JavaScript:;"   
  onClick="cal1.select(document.forms[0].eventdate,'calendar1here','MM/dd/yy'); return    
  false;"&gt;
 &lt;img src="resources/calendar.gif" alt="Calendar Icon" width="20" height="20"   
 border="0"&gt;&lt;/a&gt;
 &lt;/td&gt;
 &lt;/tr&gt;

 &lt;tr&gt;
 &lt;td align="right" valign="center"&gt;&lt;b&gt;&lt;? displayformlabel('throughdate','Through:')?&gt;  
 &lt;/b&gt;&lt;/td&gt;
 &lt;td&gt;&lt;input name="throughdate" value="&lt;? echo $qry_event1['throughdate']; ?&gt;"&gt;
 &lt;a name="calendar2here" id="calendar2here" href="JavaScript:;" 
 onClick="cal2.select(document.forms[0].throughdate,'calendar2here','MM/dd/yy'); return    
 false;"&gt;
 &lt;img src="resources/calendar.gif" alt="Calendar Icon" width="20" height="20" 
 border="0"&gt;&lt;/a&gt;
 &lt;span class="formnotes"&gt;Leave blank if only one day event&lt;/span&gt;
 &lt;/td&gt;
 &lt;/tr&gt;

 &lt;tr&gt;
 &lt;td align="right"&gt;&lt;b&gt;&lt;? displayformlabel('title','Event Title:')?&gt;&lt;/b&gt;&lt;/td&gt;
 &lt;td&gt;&lt;input name="title" size="50" maxlength="50" value="&lt;? echo $qry_event1['title'];? 
  &gt;"&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td align="right"&gt;&lt;? displayformlabel('website','Event Website:')?&gt;&lt;/td&gt;
 &lt;td&gt;&lt;input name="website" size="50" maxlength="100" value="&lt;? echo 
 $qry_event1['website']; ?&gt;"&gt;&lt;/td&gt;
 &lt;/tr&gt;

 &lt;tr&gt;
 &lt;td align="right"&gt;&lt;? displayformlabel('email','Event Email:')?&gt;&lt;/td&gt;
 &lt;td&gt;&lt;input name="email" size="50" maxlength="100" value="&lt;? echo   
 $qry_event1['email'];?&gt;"&gt;&lt;/td&gt;
 &lt;/tr&gt;

 &lt;tr&gt;
 &lt;td align="right" valign="top"&gt;&lt;? displayformlabel('notes','Notes:')?&gt;&lt;/td&gt;
 &lt;td&gt;&lt;textarea name="notes" style="width: 320px; height: 60px;"&gt;&lt;? echo  
 $qry_event1['notes']; ?&gt;&lt;/textarea&gt;&lt;/td&gt;
 &lt;/tr&gt;

 &lt;tr&gt;
 &lt;td align="right"&gt;&lt;? displayformlabel('venue','Venue:')?&gt;&lt;/td&gt;

 &lt;td&gt;&lt;input name="venue" size="50" maxlength="50" value="&lt;? echo $qry_event1['venue'];?  
  &gt;"&gt;&lt;/td&gt;
 &lt;/tr&gt;

 &lt;tr&gt;
 &lt;td align="right"&gt;&lt;? displayformlabel('address','Address:')?&gt;&lt;/td&gt;

 &lt;td&gt;&lt;input name="address" size="50" maxlength="50" value="&lt;?echo   
 $qry_event1['address'];?&gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
  &lt;td align="right"&gt;&lt;? displayformlabel('city','City:')?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="city" size="50" maxlength="50" value="&lt;?echo $qry_event1['city'];?  
   &gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;

   &lt;tr&gt;
  &lt;td align="right"&gt;&lt;? displayformlabel('state','State:')?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="state" size="3" maxlength="2" value="&lt;?echo $qry_event1['state'];?
   &gt;"&gt;&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
  &lt;td align="right"&gt;&lt;? displayformlabel('lat','Latitude:')?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="lat" size="15" maxlength="15" value="&lt;? echo $qry_event1['lat'];?&gt;"&gt;  
  &lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
  &lt;td align="right"&gt;&lt;? displayformlabel('lon','Longitude:')?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="lon" size="15" maxlength="15" value="&lt;? echo $qry_event1['lon'];?&gt;"&gt;
  &amp;nbsp; &amp;nbsp;
  &lt;span class="formnotes"&gt;&lt;a href="JavaScript:;" onclick="lookUp()"&gt;Look up&lt;/a&gt;    
   coordinates using above address information.&lt;/span&gt;
  &lt;/td&gt;
 &lt;/tr&gt;

  &lt;tr&gt;
  &lt;td align="right"&gt;&lt;? displayformlabel('accurate','Accurate:')?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input name="accurate" type="checkbox" value="1" &lt;?php if   
  (isset($qry_event1['accurate'])) { echo 'checked="checked"'; }?&gt;&gt;
  &amp;nbsp; &amp;nbsp; &lt;a href="JavaScript:;" class="formnotes" onClick="window.open('&lt;?php   
  print $vsf-&gt;self;?&gt;?action=accuratehelp','helpwin','width=435,height=220');"&gt;Whats  
   this?&lt;/a&gt; 
  &lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input type="submit" value="Submit"&gt;&lt;/td&gt;
  &lt;/tr&gt;

  &lt;/table&gt;

  &lt;/form&gt;
</code></pre>

<p>Update page:</p>

<pre><code>&lt;?php
 // updates a record in the database

 // do validation (shared with update logic)
 $id = $_REQUEST['id'];
  $eventdate = $_REQUEST['eventdate'];
  $throughdate = $_REQUEST['throughdate'];
  $title = $_REQUEST['title'];
   $website = $_REQUEST['website'];
  $email = $_REQUEST['email'];
 $notes = $_REQUEST['notes'];
 $venue = $_REQUEST['venue'];
 $address = $_REQUEST['address'];
 $city = $_REQUEST['city'];
 $state = $_REQUEST['state'];
 $lat = $_REQUEST['lat'];
 $lon = $_REQUEST['lon'];
 $accurate = $_REQUEST['accurate'];
 $errorwasthrown="";


 $database = 'mapcal';

 // database server
$dbsvr = 'localhost';

// username
$dbuser = 'root';

// password
$dbpass = 'usbw'; 
function db_connect() {
 global $dbsvr,$dbuser,$dbpass,$database;
 static $dbcon;

 if ( ! $dbcon ) {

$dbcon = mysql_connect($dbsvr,$dbuser,$dbpass);

if (! mysql_select_db($database) ) {
  die("Failure connecting to database - " . mysql_error());
  }
 }
 }
 if (! $eventdate ) {
adderrmsg('eventdate','Event date cannot be blank.');
$errorwasthrown=1;
 }
else {
// else date wasn't blank, so validate it
 if (! preg_match("/^\d\d\/\d\d\/\d\d$/",$eventdate) ) {
 adderrmsg('eventdate',"Event date must be in format mm/dd/yy.");
 $errorwasthrown=1;
 }
 }

 if ($throughdate &amp;&amp; ! preg_match("/^\d\d\/\d\d\/\d\d$/",$throughdate) ) {
 adderrmsg('throughdate',"Through date must be in format mm/dd/yy.");
 $errorwasthrown=1;
 }

 if (! $title ) {
 adderrmsg('title','Title cannot be blank.');
 $errorwasthrown=1;
 }




 if ($errorwasthrown) {
  include('dsp_editevent.php');

 }
 else {

 db_connect();

 // format the date correctly for mysql
 $dateparts = split("/",$eventdate);
 $eventdate = "$dateparts[2]/$dateparts[0]/$dateparts[1]";

  if ($throughdate) {
  $dateparts = split("/",$throughdate);
  $throughdate = "$dateparts[2]/$dateparts[0]/$dateparts[1]";
  $throughdate = "'" . mysql_real_escape_string($throughdate) . "'";
  }
 else {
$throughdate = 'NULL';
}

// format event website if necessary
 if ($website &amp;&amp; ! preg_match("/:\/\//",$website) ) {
$website = "http://" . $website;
 }

 // update record in the database
 $query = "UPDATE events SET ";
 $query .= "eventdate = '" . mysql_real_escape_string($eventdate) . "', " .
        "throughdate = " . $throughdate . ", " .
        "title = '" . mysql_real_escape_string($title)  . "', " .
        "website = '" . mysql_real_escape_string($website)  . "', " .
        "email = '" . mysql_real_escape_string($email)  . "', " .
        "notes = '" . mysql_real_escape_string($notes)  . "', " .
        "venue = '" . mysql_real_escape_string($venue)  . "', " .
        "address = '" . mysql_real_escape_string($address)  . "', " .
        "city = '" . mysql_real_escape_string($city)  . "', " .
        "state = '" . mysql_real_escape_string($state)  . "', " .
        "lat = '" . mysql_real_escape_string($lat)  . "', " .
        "lon = '" . mysql_real_escape_string($lon)  . "', " .
        "accurate = '" . mysql_real_escape_string($accurate)  . "' " .
        "WHERE id = " . mysql_real_escape_string($id);

    if ( ! mysql_query($query) ) {
    exit("Query failed! - $query");
   }

  print "&lt;p style='color: green'&gt;Event &lt;b&gt;$title&lt;/b&gt; was updated.&lt;/p&gt;\n";
  include('dsp_listevents.php');

   } // close else ! errorwasthrown




   ?&gt; 
</code></pre>

<p>What i can see after printing the query is that it is not getting the value of id but all the fields from the form but why?</p>
