phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

what code to use to update sql table?


 
Search this topic... | Search General Support... | Search Box
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Author Message
guyb
Board Member



Joined: 30 Sep 2009

Posts: 11



PostPosted: Tue Oct 13, 2009 7:45 am 
Post subject: what code to use to update sql table?

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
Citrix
Board Member



Joined: 19 Feb 2012

Posts: 42



PostPosted: Wed Feb 22, 2012 7:35 pm 
Post subject: Re: what code to use to update sql table?

Code:
$data_input = $HTTP_POST_VARS['data_input'];
//but this is better since it checks is the data was posted.
$data_input = ( isset($HTTP_POST_VARS['data_input']) ) ? $HTTP_POST_VARS['data_input'] : "";
if (strlen($data_input)) //update database if we have new data.
{
   UPDATE phpbb_table name SET field_name = '$data_input' WHERE 'condidtions goes here';
}
This should do it.

Let's bring this support site alive. phpbb2 is not going away.
Back to top
Display posts from previous:   
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0284 seconds using 15 queries. (SQL 0.0020 Parse 0.0008 Other 0.0256)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo