I am working on a "Call Log" application for our SA group.  I
currently have the database back-end configured and working OK.  Right now I
am working with 3 pages, one is to post new entries, the second is a log
view of all entries, and the last is a page that updates an existing entry.
I have the first two pages working OK.  The problem is the update page does
not post back into the database.  
        I am working in Dreamweaver, and I am still quite new to PHP and web
page development in general.  I am not sure what some of the DreamWeaver PHP
code is doing, and I cannot figure out why I am not able to get the update
page to post to the database.  The update page is connecting successfully to
the database, because I have it's fields populated from the database for the
entry to be updated.  One other minor issue I am having, is getting a PHP
variable to populate a text area on the page.  Is this even possible?
        Thanks in advance, and below is the code for the problem page.

<?php require_once('Connections/Test.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
"NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"]
== "form1")) {
  $updateSQL = sprintf("UPDATE oncall SET sa=%s, ptime=%s, rtime=%s,
sbcuid=%s, name=%s, problem=%s, resolution=%s, pass=%s, ctime=%s,
duration=%s, ttrp=%s, feedback=%s, P1=%s WHERE callid=%s",
                       GetSQLValueString($HTTP_POST_VARS['sa'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['ptime'], "date"),
                       GetSQLValueString($HTTP_POST_VARS['rtime'], "date"),
                       GetSQLValueString($HTTP_POST_VARS['sbcuid'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['name'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['problem'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['resolution'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['pass'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['ctime'], "date"),
                       GetSQLValueString($HTTP_POST_VARS['duration'],
"date"),
                       GetSQLValueString($HTTP_POST_VARS['ttrp'], "date"),
                       GetSQLValueString($HTTP_POST_VARS['feedback'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['P1'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['callid'], "int"));

  mysql_select_db($database_Test, $Test);
  $Result1 = mysql_query($updateSQL, $Test) or die(mysql_error());
}

$tmp = $_GET['callid'];
mysql_select_db($database_Test, $Test);
$query_Update = "SELECT * FROM oncall WHERE callid='$tmp'";
$Update = mysql_query($query_Update, $Test) or die(mysql_error());
$row_Update = mysql_fetch_assoc($Update);
$totalRows_Update = mysql_num_rows($Update);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <input type="hidden" name="callid" value="<?php echo
$row_Update['callid']; ?>">
  <input type="hidden" name="feedback" value="<?php echo
$row_Update['feedback']; ?>">
  <table width="666" align="center">
    <!--DWLayoutTable-->
    <tr valign="baseline"> 
      <td width="122" height="24" align="right" nowrap>SA name:</td>
      <td colspan="2"><input type="text" name="sa" value="<?php echo
$row_Update['sa']; ?>" size="32"></td>
      <td width="39">&nbsp;</td>
      <td width="124" align="right" valign="top" nowrap>Call passed to:</td>
      <td colspan="2" valign="top"><input type="text" name="pass"
value="<?php echo $row_Update['pass']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline"> 
      <td height="24" align="right" nowrap>Time of page:</td>
      <td colspan="2"><input type="text" name="ptime" value="<?php echo
$row_Update['ptime']; ?>" size="32"></td>
      <td></td>
      <td></td>
      <td width="11"></td>
      <td width="177"></td>
    </tr>
    <tr valign="baseline"> 
      <td height="24" align="right" nowrap>Time page returned:</td>
      <td colspan="2"><input type="text" name="rtime" value="<?php echo
$row_Update['rtime']; ?>" size="32"></td>
      <td>&nbsp;</td>
      <td align="right" valign="top" nowrap>Call completion time:</td>
      <td colspan="2" valign="top"><input type="text" name="ctime"
value="<?php echo $row_Update['ctime']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline"> 
      <td height="24" align="right" nowrap>SBCUID of client:</td>
      <td colspan="2"><input type="text" name="sbcuid" value="<?php echo
$row_Update['sbcuid']; ?>" size="32"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline"> 
      <td height="24" align="right" nowrap>Name of client:</td>
      <td colspan="2"><input type="text" name="name" value="<?php echo
$row_Update['name']; ?>" size="32"></td>
      <td>&nbsp;</td>
      <td align="right" valign="top" nowrap>P1 Vantive ID:</td>
      <td colspan="2" valign="top"><input type="text" name="P1" value="<?php
echo $row_Update['P1']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline"> 
      <td height="24" align="right" nowrap>Problem description:</td>
      <td colspan="5" rowspan="3" valign="top"><textarea name="problem"
value="<?php echo $row_Update['problem']; ?>" cols="40" rows="6"></textarea>

      </td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline"> 
      <td height="46">&nbsp;</td>
      <td valign="top">Limit of 255 characters.</td>
    </tr>
    <tr valign="baseline"> 
      <td height="53">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline"> 
      <td height="24" align="right" valign="top" nowrap>Resolution:</td>
      <td colspan="5" rowspan="3" valign="top"><textarea name="resolution"
value="<?php echo $row_Update['resolution']; ?>" cols="40"
rows="6"></textarea></td>
      <td></td>
    </tr>
    <tr valign="baseline"> 
      <td height="53">&nbsp;</td>
      <td valign="top">Limit of 255 characters.</td>
    </tr>
    <tr valign="baseline"> 
      <td height="39">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline"> 
      <td height="26" align="right" nowrap>&nbsp;</td>
      <td width="91" valign="top"><input type="submit" value="Insert
Record"> 
      </td>
      <td width="94">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td></td>
      <td></td>
    </tr>
  </table>
  
</form>
<p>&nbsp;</p>
  
<p>&nbsp;</p>
  </body>
</html>
<?php
mysql_free_result($Update);
?>


Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to