Here's the code: with some extraneous html removed to make it easier to

<? require('connect.php') ?>

/* check  for  a request to display a new fg number and if so make sure the
data is good
if the fg number is good it is used for all other data queries */
 if  ($switchfg !==""){
$switchfg = htmlentities($switchfg , ENT_QUOTES);
      if (strlen($switchfg) > 7) {
      echo "bad fg number";
      else {
      $fgNumber =$switchfg ;
      echo $fgNumber;

This works... I added the echo statement in the last line for debugging
purposes, the page does indeed display the fgNumber, and uses the variable
to perform other queries, which also work... until I try to update the


if ($tableid=="products") {
echo "updating products";
      if ($productName !=""  and  $productDescription !="") {
      $products_query= "UPDATE products SET productName='$productName',
productDescription='$productDescription' where fgNumber='$fgNumber' limit
      $productsResult = mysql_query($products_query);
      echo $products_query;

Again, that last line is a debugging entry, and it echoes back the query
I'm expecting, except that the variable $fgNumber looses it's value
somewhere and the query looks like this:

UPDATE products SET productName='ZR-4630 MultiZone Receiver',
productDescription='4-Source 6-Zone Receiver with AM/FM Tuner' where
fgNumber='' limit 1

I expect it to say " where fgNumber='FG00813"

Here's the form that triggers the update

<!-- ______________________________________ PRODUCTS TABLE
______________________________________ -->
$productsQuery ="SELECT id, fgNumber, productName, productDescription FROM
products where fgNumber='$fgNumber' ";
$productsRecordset = mysql_query($productsQuery) or die(mysql_error());
<form name="products" method="post" action="<? $_SERVER['php_self']
?>"><input name="tableid" type="hidden" value="products">
<table width="100%" border="0" cellpadding="10" cellspacing="0" bgcolor="
                        <td colspan="4"><h2>Products Table</h2>
                        <input name="productId" type="text" id="productId"
value="<? echo $productsRow['id'] ?>" size="5"></td>
                                    <input name="fgNumber" type="text" id
="fgNumber" value="<? echo $productsRow['fgNumber'] ?>" size="10"></td>
                                    <input name="productName" type="text"
id="productName" value="<? echo $productsRow['productName'] ?>" size
                                    <input name="productDescription" type
="text" id="productDescription" value="<? echo $productsRow
['productDescription'] ?>" size="48"></td>
                        <td colspan="4">Update Product Information
                        <input type="submit" name="Submit" value

I keep looking for an error and not finding one, am I missing something


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to