phpbb-auction.com Forum Index phpbb-auction.com
Download, Support, Documentation
 
Donate to phpbb-auction.com to support the project


phpbb-Auction
  Home
   - News
   - Bug report/Patches
   - Future Features
  Demo
  Downloads
   - Version 1.3m  (Core /Lang /Mods)
   - Version 1.2m  (Core /Lang /Mods)
   - Version 1.0m  (Core /Lang /Mods)
   - All
  Services
  Documentation
   - Features
   - Documents
   - How-Tos
   - About
  Support
   - English
   - German
  Development
   - Changlog
   - Requests
   - Team
   - CVS
  Community
   - Website of the Month
   - Websites
   - Community Forum
   - Member

Navigation
FAQFAQ
SearchSearch
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesLog in to check your private messages
Log inLog in

Forum
Changing start time auctions
Sun Feb 07, 2010 4:33 am FR
Easy: what code to use to update sql table?
Fri Oct 16, 2009 8:39 am guyb
Unlimited products(downloads)
Wed Oct 14, 2009 7:09 pm hoimyr
Seller chooses currency
Sun Oct 11, 2009 8:00 pm hoimyr
Cant select end date without getting error
Sun Oct 11, 2009 6:43 pm hoimyr

About
Author: FR
Credits:
Brookfresh, Brad Lawryk, Crogon, DaMysterious, EklipzeDesigns, ML, musashi, phpBB Group, phpBB-Auction-Team, php-styles, sanman, Tel, Vampy, wGEric

Supported Sites





Statistics
User: 16573
Posts: 18401
Latest User: awibzidutib

Easy: what code to use to update sql table?

 
Post new topic   Reply to topic    phpbb-auction.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
guyb
Small-Cap Auctioneer
Small-Cap Auctioneer


Joined: 22 Oct 2008
Posts: 21

PostPosted: Tue Oct 13, 2009 7:52 am    Post subject: Easy: what code to use to update sql table? Reply with quote

A relative easy question that I don't know the answer to: I'm trying to receive data from form fields and upload them into an sql table, but I've seen variations of sql UPDATEs and I don't know which kind to use.

I've seen data received in like this:
Code:
$data_input = $HTTP_POST_VARS['data_input'];


Or like this:
Code:
$data_input = ( isset($HTTP_POST_VARS['data_input']) ) ? $HTTP_POST_VARS['data_input'] : $HTTP_GET_VARS['data_input'];


and used to UPDATE sql like this:
Code:
data_input = '" . $data_input . "',


But I've also seen sql UPDATEd like this:
Code:
forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ",


and like this (with ''):
Code:
topic_last_poster_id = '$topic_last_poster_id',


Or this (without ''):
Code:
session_time = $current_time,


Can anyone give me some direction as to what goes with what and when?
Back to top
View user's profile Send private message
FR
Site Admin
Site Admin


Joined: 26 Jan 2004
Posts: 1764
Location: root directory

PostPosted: Wed Oct 14, 2009 4:17 am    Post subject: Reply with quote

on your first to options:
the first one just works with HTTP POST.. on one of my new servers just the HTTP_GET works. therefore the second query will function with both settings. the first query will just work with POST.

on the UPDATE field
the function intval() transforms the input into an integer value. the first example (Code #3) is for a string or text (thats also the reason you have the '" . $variable . "'

on your last two examples:
The second one (last code example from you) compares values /numbers. you do not need the little ' (do not know the english word) for it. the first one (second last code example) compares a string / text which requires the little '

Hope it helps.
_________________
Want to say thank you. Use my Amazon Wishlist
Meet the world on movie-on.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
guyb
Small-Cap Auctioneer
Small-Cap Auctioneer


Joined: 22 Oct 2008
Posts: 21

PostPosted: Fri Oct 16, 2009 8:39 am    Post subject: Reply with quote

Thanks! That helped me clear up a lot of my sql UPDATE coding.

I have a follow-up question though: I can't get checkbox values to be processed correctly. Originally selected values display fine, but subsequent changes which I UPDATE seem to override any future changes I make.

Working backwards, here's how my 3 checkboxes are assigned to the template:


Code:
                     'AUCTION_OFFER_BOLD_CHECKED' => ( $offer_rowset[$i]['auction_offer_bold']) ? "checked=\"checked\"" : "",
                     'AUCTION_OFFER_ON_TOP_CHECKED' => ( $offer_rowset[$i]['auction_offer_on_top']) ? "checked=\"checked\"" : "",
                     'AUCTION_OFFER_SPECIAL_CHECKED' => ( $offer_rowset[$i]['auction_offer_special']) ? "checked=\"checked\"" : "",


And here are 4 different ways I've tried to receive default or edited values:
1.
Code:
$auction_offer_special = ( isset($HTTP_POST_VARS['offer_special']) ) ? ( ($HTTP_POST_VARS['offer_special']) ? TRUE : 0 ) : $HTTP_GET_VARS['offer_special'];


2.
Code:
   $auction_offer_special = $HTTP_POST_VARS['offer_special'];


3.
Code:
                if (empty($HTTP_POST_VARS['offer_special']) )
                      {
                           $auction_offer_special = 0;
                      }
                 else
                      {
                           $auction_offer_special = 1;
                      }


4.
Code:
$auction_offer_special = ( isset($HTTP_POST_VARS['offer_special']) ) ? intval( $HTTP_POST_VARS['offer_special'] ) : 0;



My sql UPDATE for them looks like this:
Code:
auction_offer_special = $auction_offer_special,
auction_offer_on_top = $auction_offer_on_top,
auction_offer_bold = $auction_offer_bold
WHERE PK_auction_offer_id ='" . $offer_id . "'";


Depending on which of the 4 methods above I use I sometimes get a debugging error regarding returned values of "on". Any ideas which way I'm supposed to code to receive checkbox values?

My customization is based on your existing coding and for these 3 values I noticed in "auction_offer" different references to the variables, like "offer_special" and "auction_offer_special". Am I perhaps supposed to use "auction_offer_special" all the time?

(I fixed an oversight on your "auction_store" pages with the radio buttons which weren't getting updated after selection - there, with yes/no radio buttons I can update intval selections but with intval checkboxes with 0/1 values like above I can't seem to get it)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    phpbb-auction.com Forum Index -> Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


phpbb-auction.com - Developed by www.digital-media-lab.com
Sponsored by: www.globibo.com - www.learn2go.de - www.talentone.org - www.language-school.in - www.ping-ke.cn