query problem
| From: | Jennifer Swofford | Date: | Mon, 21 Oct 2002 21:05:06 +0000 |
| Subject: | query problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-120803@lists.php.net to get a copy of this message | ||
I am in need of fresh eyes and brains. :)
I have a database full of products. The client needs to be able to update the products in the
database, so I set up a maintenance area for them to do so. They are able to view the product
details, edit the details, and then submit the changes. All very standard, in a form, using php and
mysql.
And it was working fine, or so I thought, until recently.
The client was doing a whole batch of updates... and it seems that the query works for some items
and not for others. For instance, I have a category called "Auto and Garage", and of the
7 items in that category, only 1 is updatable. In the "For the Birds" category, 12 of the
20 items are updatable. It is always the same items that fail.
The page that does the editing is called edit_product.php, and the query looks like this:
mysql_query("UPDATE products SET prod_name='$prod_name',
prod_sku='$prod_sku', prod_price='$prod_price',
prod_sdesc='$prod_sdesc', prod_ldesc='$prod_ldesc',
prod_cat='$prod_cat', itemnum='$itemnum', assoc='$assoc',
best_seller='$best_seller' where ID = '$prod_ID'");
To test, I've added lines that echo each of those values, including $prod_ID, which is the most
important. (When I went to debug, I noticed that $prod_ID was not in quotes, and then I added the
quotes, but it still doesn't work... I always forget the proper quoting convention.) And they
all echo just fine. It's trying to update the product with ID of 12, for instance, and it
echoes "12" for $prod_ID, and it seems like it has all the right values... but the
database ain't getting updated. Looking at the ID numbers, and the rest of the field values, I
can't see any pattern. (I was hoping to find a problem with the items that had quotes, or that
started with the number "1", or some such... but no luck so far.)
Now, is it obvious to everyone what I'm overlooking here? Can anyone tell me what else to do
to try to debug this?
Eternal thanks in advance,
Jen