Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-02-2010, 08:09 PM   PM User | #1
MrEnder
Regular Coder

 
MrEnder's Avatar
 
Join Date: Jul 2008
Location: Canada Ontario
Posts: 258
Thanks: 18
Thanked 4 Times in 4 Posts
MrEnder can only hope to improve
Updating specific area of table in postgresql

Ok I am trying to update a specific area of a table in postgresql

I want it to find the user that goes along with the table

and then update the information I have

like in this case the email is the user name that it needs to look for.

it needs to add in areas like $aboutSelf, $hobbies, $music, $tv, $sports

so ya I have no idea how to do this lol ^.^ I only know how to add stuff from scratch. like create a non existing user
__________________
Continually Learning
MrEnder is offline   Reply With Quote
Old 04-02-2010, 08:29 PM   PM User | #2
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
You want to add more columns to the user table and add info to those columns for one user, or just update existing columns for one specific user?
MattF is offline   Reply With Quote
Old 04-02-2010, 08:45 PM   PM User | #3
MrEnder
Regular Coder

 
MrEnder's Avatar
 
Join Date: Jul 2008
Location: Canada Ontario
Posts: 258
Thanks: 18
Thanked 4 Times in 4 Posts
MrEnder can only hope to improve
update existing blank colums for the user

Code:
DROP TABLE chatterprofileinfo;

CREATE TABLE chatterprofileinfo(
	Id SERIAL,
	email VARCHAR(255) NOT NULL PRIMARY KEY,
	aboutSelf VARCHAR(255),
	hobbies VARCHAR(255),
	music VARCHAR(255),
	tv VARCHAR(255),
	sports VARCHAR(255),
	lastLogin DATE
);
that is the SQL email is already filled in and is the username so i need to somehow find specific email and put in stuff according to the email

currently trying to use

$query = pg_query("UPDATE chatterprofileinfo SET aboutSelf='$aboutSelf', hobbies='$hobbies', music='$music', tv='$tv', sports='$sports', lastLogin='now()' WHERE email='$username'");

and i dont think its working
__________________
Continually Learning

Last edited by MrEnder; 04-02-2010 at 09:06 PM..
MrEnder is offline   Reply With Quote
Old 04-02-2010, 09:09 PM   PM User | #4
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Code:
UPDATE chatterprofileinfo SET hobbies='[new hobby]', sports='[new sports]' WHERE email='email@example.org';
Obviously, replace the bracketed portions with the info you're actually entering.


Edit: You edited whilst I was typing. Try this and see if it prints an error.

Code:
$query = pg_query("UPDATE chatterprofileinfo SET aboutSelf='$aboutSelf', hobbies='$hobbies', music='$music', tv='$tv', sports='$sports', lastLogin='now()' WHERE email='$username'") or exit(pg_last_error());

Last edited by MattF; 04-02-2010 at 09:12 PM..
MattF is offline   Reply With Quote
Old 04-03-2010, 01:25 PM   PM User | #5
MrEnder
Regular Coder

 
MrEnder's Avatar
 
Join Date: Jul 2008
Location: Canada Ontario
Posts: 258
Thanks: 18
Thanked 4 Times in 4 Posts
MrEnder can only hope to improve
that works with the exception that its being put into an area with no e-mail and the e-mail is disappearing 0.0

(sorry for the late reply I fell asleep at the PC lol)
__________________
Continually Learning
MrEnder is offline   Reply With Quote
Old 04-03-2010, 05:50 PM   PM User | #6
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
Quote:
Originally Posted by MrEnder View Post
that works with the exception that its being put into an area with no e-mail and the e-mail is disappearing 0.0
That means, exactly?
MattF is offline   Reply With Quote
Old 04-03-2010, 09:39 PM   PM User | #7
MrEnder
Regular Coder

 
MrEnder's Avatar
 
Join Date: Jul 2008
Location: Canada Ontario
Posts: 258
Thanks: 18
Thanked 4 Times in 4 Posts
MrEnder can only hope to improve
ok when i print out the database there is nothing in the email slot thats what i mean. so its posting stuff when there isnt even that area =[
__________________
Continually Learning
MrEnder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:45 AM.


Advertisement
Log in to turn off these ads.