...

View Full Version : Updating specific area of table in postgresql



MrEnder
04-02-2010, 08:09 PM
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

MattF
04-02-2010, 08:29 PM
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?

MrEnder
04-02-2010, 08:45 PM
update existing blank colums for the user


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

MattF
04-02-2010, 09:09 PM
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. :D Try this and see if it prints an error.



$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());

MrEnder
04-03-2010, 01:25 PM
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)

MattF
04-03-2010, 05:50 PM
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?

MrEnder
04-03-2010, 09:39 PM
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 =[



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum