/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] MySQL Insert

Hello,

I have a sign up form where their are 5different text boxes for the address.

House name/number & street,
City,
County,
Postcode,
Country

I want to insert these 5 fields into 1 MySQL Table column ‘address’.

I have tried loads of different ways to insert them although non are seeming to work.

below is my example:

[code=php]
$cw=mysql_query(“update users(address) values(‘$firstlineaddress $city $county $postcode $country’) where userid=’$userid’;”);
[/code]

I would be extremely grateful for any help towards this.

Many Thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bionoidFeb 21.2012 — I am assuming that the variables being used in the statement were previously defined:

[code=php]$firstlineaddress = $_POST['firstlineaddress'];
$city = $_POST['city'];
//etc[/code]


If you want to do an update you should write it like this:

[code=php]$cw = mysql_query("UPDATE users SET address = '$firstlineaddress $city $county $postcode $country' WHERE userid = '$userid'");[/code]

If you want to do an insert, write it more like this:

[code=php]$cw = mysql_query("INSERT INTO users (address) VALUES ('$firstlineaddress $city $county $postcode $country')");[/code]

I will ask about how the data is being escaped if this is what you're looking for.
Copy linkTweet thisAlerts:
@thewebportfolioauthorFeb 21.2012 — Thank you, works great! Much appreciated?
×

Success!

Help @thewebportfolio spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...