[PHP-DB] form not working...

2003-11-10 Thread jas
For some reason my form to edit selected items is not working, I think I
need a new set of eyes.
Any help is appreciated...
Jas

// inc.php
function db_retrieve() {
 require 'dbase.inc.php';
 $tble = $_SESSION['table'];
 $show = @mysql_query(SELECT * FROM $tble LIMIT 0, 15,$db)or
die(mysql_error());
   while ($row = @mysql_fetch_array($show)) {
@list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
 $_SESSION['table'] .= tr class=fntMAINtd valign=top
align=left$nItemSKU/td
 td valign=top align=left$bActive/td
 td valign=top align=left$nUserID/td
 td valign=top align=left$nItemConfig/td
 td valign=top align=left$tItemType/td
 td valign=top align=left$tDepartment/td
 td valign=top align=left$blSerialNumber/td
 td valign=top align=left$nPropertyNumber/td
 td valign=top align=left$blHostName/td
 td valign=top align=left$nIPID/td
 td valign=top align=left$tRoomNumber/td
 td valign=top align=left$tNotes/td
 td valign=top align=leftinput name=edit type=checkbox
value=$blSerialNumber/td
/tr; }
 $_SESSION['number'] = mysql_num_rows($show); }

?php
session_start();
require 'scripts/inc.php';
if ((!isset($_POST['edit'])) or ($_POST = )) {
 $_SESSION['table'] = t_items;
 call_user_func(db_retrieve);
} elseif ((isset($_POST['edit'])) or (!$_POST = )) {
 require 'scripts/dbase.inc.php';
  $tble = $_SESSION['table'];
  $edt = mysql_query(SELECT * FROM $tble WHERE
blSerialNumber=\$edit\,$db)or die(mysql_error());
   while ($row = mysql_fetch_array($edt)) {
list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
$_SESSION['table'] .= tr class=fntMAIN
   td valign=top align=leftinput name=nItemSKU type=text size=30
value=$nItemSKU/td
   td valign=top align=leftinput name=bActive type=text size=30
value=$bActive$bActive/td
   td valign=top align=leftinput name=nUserID type=text size=30
value=$nUserID$nUserID/td
   td valign=top align=leftinput name=nItemConfig type=text
size=30 value=$nItemConfig$nItemConfig/td
   td valign=top align=leftinput name=tItemType type=text size=30
value=$tItemType$tItemType/td
   td valign=top align=leftinput name=tDepartment type=text
size=30 value=$tDepartment$tDepartment/td
   td valign=top align=leftinput name=blSerialNumber type=text
size=30 value=$blSerialNumber$blSerialNumber/td
   td valign=top align=leftinput name=nPropertyNumber type=text
size=30 value=$nPropertyNumber$nPropertyNumber/td
   td valign=top align=leftinput name=blHostName type=text
size=30 value=$blHostName$blHostName/td
   td valign=top align=leftinput name=nIPID type=text size=30
value=$nIPID$nIPID/td
   td valign=top align=leftinput name=tRoomNumber type=text
size=30 value=$tRoomNumber$tRoomNumber/td
   td valign=top align=leftinput name=tNotes type=text size=30
value=$tNotes$tNotes/td
   td valign=top align=leftinput name=save type=button value=Save
class=frmBTNS/td
  /tr; }
}
?
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
?php echo $_SESSION['table']; ?
input name=edit type=button value=edit selected items
class=frmBTNS
/form

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



RE: [PHP-DB] form not working...

2003-11-10 Thread Gary Every
Don't you need to start your form BEFORE your input type's

-Original Message-
From: jas [mailto:[EMAIL PROTECTED]
Sent: Monday, November 10, 2003 11:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] form not working...


For some reason my form to edit selected items is not working, I think I
need a new set of eyes.
Any help is appreciated...
Jas

// inc.php
function db_retrieve() {
 require 'dbase.inc.php';
 $tble = $_SESSION['table'];
 $show = @mysql_query(SELECT * FROM $tble LIMIT 0, 15,$db)or
die(mysql_error());
   while ($row = @mysql_fetch_array($show)) {
@list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
 $_SESSION['table'] .= tr class=fntMAINtd valign=top
align=left$nItemSKU/td
 td valign=top align=left$bActive/td
 td valign=top align=left$nUserID/td
 td valign=top align=left$nItemConfig/td
 td valign=top align=left$tItemType/td
 td valign=top align=left$tDepartment/td
 td valign=top align=left$blSerialNumber/td
 td valign=top align=left$nPropertyNumber/td
 td valign=top align=left$blHostName/td
 td valign=top align=left$nIPID/td
 td valign=top align=left$tRoomNumber/td
 td valign=top align=left$tNotes/td
 td valign=top align=leftinput name=edit type=checkbox
value=$blSerialNumber/td
/tr; }
 $_SESSION['number'] = mysql_num_rows($show); }

?php
session_start();
require 'scripts/inc.php';
if ((!isset($_POST['edit'])) or ($_POST = )) {
 $_SESSION['table'] = t_items;
 call_user_func(db_retrieve);
} elseif ((isset($_POST['edit'])) or (!$_POST = )) {
 require 'scripts/dbase.inc.php';
  $tble = $_SESSION['table'];
  $edt = mysql_query(SELECT * FROM $tble WHERE
blSerialNumber=\$edit\,$db)or die(mysql_error());
   while ($row = mysql_fetch_array($edt)) {
list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
$_SESSION['table'] .= tr class=fntMAIN
   td valign=top align=leftinput name=nItemSKU type=text size=30
value=$nItemSKU/td
   td valign=top align=leftinput name=bActive type=text size=30
value=$bActive$bActive/td
   td valign=top align=leftinput name=nUserID type=text size=30
value=$nUserID$nUserID/td
   td valign=top align=leftinput name=nItemConfig type=text
size=30 value=$nItemConfig$nItemConfig/td
   td valign=top align=leftinput name=tItemType type=text size=30
value=$tItemType$tItemType/td
   td valign=top align=leftinput name=tDepartment type=text
size=30 value=$tDepartment$tDepartment/td
   td valign=top align=leftinput name=blSerialNumber type=text
size=30 value=$blSerialNumber$blSerialNumber/td
   td valign=top align=leftinput name=nPropertyNumber type=text
size=30 value=$nPropertyNumber$nPropertyNumber/td
   td valign=top align=leftinput name=blHostName type=text
size=30 value=$blHostName$blHostName/td
   td valign=top align=leftinput name=nIPID type=text size=30
value=$nIPID$nIPID/td
   td valign=top align=leftinput name=tRoomNumber type=text
size=30 value=$tRoomNumber$tRoomNumber/td
   td valign=top align=leftinput name=tNotes type=text size=30
value=$tNotes$tNotes/td
   td valign=top align=leftinput name=save type=button value=Save
class=frmBTNS/td
  /tr; }
}
?
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
?php echo $_SESSION['table']; ?
input name=edit type=button value=edit selected items
class=frmBTNS
/form

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

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



Re: [PHP-DB] form not working...

2003-11-10 Thread jeffrey_n_Dyke

i'd be curious what your actual problem is?

here's a question though.,...would these ever work?.
snip
if ((!isset($_POST['edit'])) or ($_POST = )) {
 $_SESSION['table'] = t_items;
 call_user_func(db_retrieve);
} elseif ((isset($_POST['edit'])) or (!$_POST = )) {
/snip

You're basically setting a superglobal array equal to an empty string -
 .  this should at least be $_POST == ...but
instead, i'd use
if ((!isset($_POST['edit'])) or (empty($_POST)) {
--and --
} elseif ((isset($_POST['edit'])) or (!empty($_POST))) {

hth
jeff



   
 
  jas
 
  [EMAIL PROTECTED]To:   [EMAIL PROTECTED]
   
  .comcc: 
 
   Subject:  [PHP-DB] form not working...  
 
  11/10/2003 12:38 
 
  PM   
 
   
 
   
 




For some reason my form to edit selected items is not working, I think I
need a new set of eyes.
Any help is appreciated...
Jas

// inc.php
function db_retrieve() {
 require 'dbase.inc.php';
 $tble = $_SESSION['table'];
 $show = @mysql_query(SELECT * FROM $tble LIMIT 0, 15,$db)or
die(mysql_error());
   while ($row = @mysql_fetch_array($show)) {
@list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
 $_SESSION['table'] .= tr class=fntMAINtd valign=top
align=left$nItemSKU/td
 td valign=top align=left$bActive/td
 td valign=top align=left$nUserID/td
 td valign=top align=left$nItemConfig/td
 td valign=top align=left$tItemType/td
 td valign=top align=left$tDepartment/td
 td valign=top align=left$blSerialNumber/td
 td valign=top align=left$nPropertyNumber/td
 td valign=top align=left$blHostName/td
 td valign=top align=left$nIPID/td
 td valign=top align=left$tRoomNumber/td
 td valign=top align=left$tNotes/td
 td valign=top align=leftinput name=edit type=checkbox
value=$blSerialNumber/td
/tr; }
 $_SESSION['number'] = mysql_num_rows($show); }

?php
session_start();
require 'scripts/inc.php';
if ((!isset($_POST['edit'])) or ($_POST = )) {
 $_SESSION['table'] = t_items;
 call_user_func(db_retrieve);
} elseif ((isset($_POST['edit'])) or (!$_POST = )) {
 require 'scripts/dbase.inc.php';
  $tble = $_SESSION['table'];
  $edt = mysql_query(SELECT * FROM $tble WHERE
blSerialNumber=\$edit\,$db)or die(mysql_error());
   while ($row = mysql_fetch_array($edt)) {
list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
$tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
$tRoomNumber, $tNotes) = $row;
$_SESSION['table'] .= tr class=fntMAIN
   td valign=top align=leftinput name=nItemSKU type=text size=30
value=$nItemSKU/td
   td valign=top align=leftinput name=bActive type=text size=30
value=$bActive$bActive/td
   td valign=top align=leftinput name=nUserID type=text size=30
value=$nUserID$nUserID/td
   td valign=top align=leftinput name=nItemConfig type=text
size=30 value=$nItemConfig$nItemConfig/td
   td valign=top align=leftinput name=tItemType type=text
   size=30
value=$tItemType$tItemType/td
   td valign=top align=leftinput name=tDepartment type=text
size=30 value=$tDepartment$tDepartment/td
   td valign=top align=leftinput name=blSerialNumber type=text
size=30 value=$blSerialNumber$blSerialNumber/td
   td valign=top align=leftinput name=nPropertyNumber type=text
size=30 value=$nPropertyNumber$nPropertyNumber/td
   td valign=top align=leftinput name=blHostName type=text
size=30 value=$blHostName$blHostName/td
   td valign=top align=leftinput name=nIPID type=text size=30
value=$nIPID$nIPID/td
   td valign=top align=leftinput name=tRoomNumber type=text
size=30 value=$tRoomNumber$tRoomNumber/td
   td valign=top align=leftinput name=tNotes type=text size=30
value=$tNotes

Re: [PHP-DB] form not working...

2003-11-10 Thread jas
Yeah, sorry that code wasn't updated... after the $_session['table'] is
called the input button doesn't attempt to post the data form the
$_session['table'] if that makes sense... all the error checking isn't the
problem
jas

Jeffrey N Dyke [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 i'd be curious what your actual problem is?

 here's a question though.,...would these ever work?.
 snip
 if ((!isset($_POST['edit'])) or ($_POST = )) {
  $_SESSION['table'] = t_items;
  call_user_func(db_retrieve);
 } elseif ((isset($_POST['edit'])) or (!$_POST = )) {
 /snip

 You're basically setting a superglobal array equal to an empty string -
  .  this should at least be $_POST == ...but
 instead, i'd use
 if ((!isset($_POST['edit'])) or (empty($_POST)) {
 --and --
 } elseif ((isset($_POST['edit'])) or (!empty($_POST))) {

 hth
 jeff




   jas
   [EMAIL PROTECTED]To:
[EMAIL PROTECTED]
   .comcc:
Subject:  [PHP-DB] form not
working...
   11/10/2003 12:38
   PM






 For some reason my form to edit selected items is not working, I think I
 need a new set of eyes.
 Any help is appreciated...
 Jas

 // inc.php
 function db_retrieve() {
  require 'dbase.inc.php';
  $tble = $_SESSION['table'];
  $show = @mysql_query(SELECT * FROM $tble LIMIT 0, 15,$db)or
 die(mysql_error());
while ($row = @mysql_fetch_array($show)) {
 @list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
 $tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
 $tRoomNumber, $tNotes) = $row;
  $_SESSION['table'] .= tr class=fntMAINtd valign=top
 align=left$nItemSKU/td
  td valign=top align=left$bActive/td
  td valign=top align=left$nUserID/td
  td valign=top align=left$nItemConfig/td
  td valign=top align=left$tItemType/td
  td valign=top align=left$tDepartment/td
  td valign=top align=left$blSerialNumber/td
  td valign=top align=left$nPropertyNumber/td
  td valign=top align=left$blHostName/td
  td valign=top align=left$nIPID/td
  td valign=top align=left$tRoomNumber/td
  td valign=top align=left$tNotes/td
  td valign=top align=leftinput name=edit type=checkbox
 value=$blSerialNumber/td
 /tr; }
  $_SESSION['number'] = mysql_num_rows($show); }

 ?php
 session_start();
 require 'scripts/inc.php';
 if ((!isset($_POST['edit'])) or ($_POST = )) {
  $_SESSION['table'] = t_items;
  call_user_func(db_retrieve);
 } elseif ((isset($_POST['edit'])) or (!$_POST = )) {
  require 'scripts/dbase.inc.php';
   $tble = $_SESSION['table'];
   $edt = mysql_query(SELECT * FROM $tble WHERE
 blSerialNumber=\$edit\,$db)or die(mysql_error());
while ($row = mysql_fetch_array($edt)) {
 list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType,
 $tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID,
 $tRoomNumber, $tNotes) = $row;
 $_SESSION['table'] .= tr class=fntMAIN
td valign=top align=leftinput name=nItemSKU type=text
size=30
 value=$nItemSKU/td
td valign=top align=leftinput name=bActive type=text size=30
 value=$bActive$bActive/td
td valign=top align=leftinput name=nUserID type=text size=30
 value=$nUserID$nUserID/td
td valign=top align=leftinput name=nItemConfig type=text
 size=30 value=$nItemConfig$nItemConfig/td
td valign=top align=leftinput name=tItemType type=text
size=30
 value=$tItemType$tItemType/td
td valign=top align=leftinput name=tDepartment type=text
 size=30 value=$tDepartment$tDepartment/td
td valign=top align=leftinput name=blSerialNumber type=text
 size=30 value=$blSerialNumber$blSerialNumber/td
td valign=top align=leftinput name=nPropertyNumber type=text
 size=30 value=$nPropertyNumber$nPropertyNumber/td
td valign=top align=leftinput name=blHostName type=text
 size=30 value=$blHostName$blHostName/td
td valign=top align=leftinput name=nIPID type=text size=30
 value=$nIPID$nIPID/td
td valign=top align=leftinput name=tRoomNumber type=text
 size=30 value=$tRoomNumber$tRoomNumber/td
td valign=top align=leftinput name=tNotes type=text size=30
 value=$tNotes$tNotes/td
td valign=top align=leftinput name=save type=button
value=Save
 class=frmBTNS/td
   /tr; }
 }
 ?
 form action=?php echo $_SERVER['PHP_SELF']; ? method=post
 ?php echo $_SESSION['table']; ?
 input name=edit type=button value=edit selected items
 class=frmBTNS
 /form

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

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



Re: [PHP-DB] Form not working...

2002-06-26 Thread Adam Royle

What you said (Mike) is mostly correct, although the GetSQLValueString() 
function in Scott's code automatically puts the quotes around the values 
if the datatype definition of text is passed to the function.

Adam


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




Re: [PHP-DB] Form not working...

2002-06-26 Thread Pierre-Alain Joye

On Wed, 26 Jun 2002 19:11:46 +1000
Adam Royle [EMAIL PROTECTED] wrote:

 What you said (Mike) is mostly correct, although the GetSQLValueString() 
 function in Scott's code automatically puts the quotes around the values 
 if the datatype definition of text is passed to the function.
 
 Adam
the link to the forum :
http://sourceforge.net/forum/forum.php?forum_id=113095

voila :)

pa

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




[PHP-DB] Form not working...

2002-06-25 Thread NIPP, SCOTT V (SBCSI)

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
titleUntitled 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 nowrapSA name:/td
  td colspan=2input type=text name=sa value=?php echo
$row_Update['sa']; ? size=32/td
  td width=39nbsp;/td
  td width=124 align=right valign=top nowrapCall passed to:/td
  td colspan=2 valign=topinput type=text name=pass
value=?php echo $row_Update['pass']; ? size=32/td
/tr
tr valign=baseline 
  td height=24 align=right nowrapTime of page:/td
  td colspan=2input 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 nowrapTime page returned:/td
  td colspan=2input type=text name=rtime value=?php echo
$row_Update['rtime']; ? size=32/td
  tdnbsp;/td
  td align=right valign=top nowrapCall completion time:/td
  td colspan=2 valign=topinput type=text name=ctime
value=?php echo 

Re: [PHP-DB] Form not working...

2002-06-25 Thread szii

okay, couple of questions in this one... =)

First...
?=$myData? is shorthand for ?php echo $myData; ? if you care.

With a textarea there is no value attribute.
  TEXTAREA?=$myData?/TEXTAREA
   
Your UPDATE call via sprintf() is okay for the parameter passing,
but you're missing single quotes around the text values.

UPDATE test SET (number = 1, name = 'the Name', Desc = 'the Desc');

When dealing with PHP and DBs, the single best thing you can do is 
var_dump($your_query) and then cut-n-paste into the command line 
utility.  It is, hands down, the single easiest (and fastest) way to figure out
why your query doesn't work.

'Luck!

-Mike



- Original Message - 
From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, June 25, 2002 11:03 AM
Subject: [PHP-DB] Form not working...


 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
 titleUntitled 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