I think i need UPDATE SYNTAX not sure.. read for deital

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

I think i need UPDATE SYNTAX not sure.. read for deital

Post by I3lade »

Ok, in my site theres a profile thing, like in these boards edit your profile. It's simple right now since im new to php, but i tried using a code to make it so they can update thier profile. Instead it inserets the info they submit into a new row in my table. Do i need to use update? If so how?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

If you are using MySQL try reading documentation on http://www.mysql.org first, it's the best thing to do.
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Yeah i tried that, its kinda confusing, its easier when u ask someone see a example of code or something to me, is there anyone who can help with update if i even need that?
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Dosn't update look something like

Code: Select all

<? UPDATE table_name SET column1=value1, column2=value2, ..., columnN=valueN &#1111;WHERE feild=value] ?>
I think thats it, but don't know how to set it up to use it in my case, which is making a profile setup. I know the html session_register ect but not the update. I think i know what goes in column not value though.
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

:( Isnt there anyone who can help me?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

їquote="I3lade"]Yeah i tried that, its kinda confusing, its easier when u ask someone see a example of code or something to me, is there anyone who can help with update if i even need that?ї/quote]

Yes it is easier, but it is wiser to do it by yourself. You will learn faster, and you'll have more pleasure when you achieve something, but....

If you want to update the database table you must use something like this:

їcode]
// for mysql

$bp = mysql_connect("localhost","login","password");
mysql_select_db("database",$bp);
mysql_query("UPDATE sth SET sth=sth, asdf=asdf, asdf=asdf,....",$bp);

ї/code]

But that's VERY simple example and HELL out of a good php script.
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Whats the sth=sth, asdf=asdf for? What do i replace with it my table feild names?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

I3lade wrote:Whats the sth=sth, asdf=asdf for? What do i replace with it my table feild names?
Right, come on! You don't want to get everything plain and easy, do you?
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

lol i know one of them is the field name im not sure what the other is, becuae i want what they put into an html form to inseret into the row.. not what i want to put..
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

So something like:

Code: Select all

$bp = mysql_connect("localhost","bladegames","****"); 
mysql_select_db("bladegames,$bp); 
mysql_query("UPDATE members SET profile=user, phob=user, $bp);
One thing i dont get... whats the $bp for?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

I3lade wrote:So something like:

Code: Select all

$bp = mysql_connect("localhost","bladegames","****"); 
mysql_select_db("bladegames,$bp); 
mysql_query("UPDATE members SET profile=user, phob=user, $bp);
One thing i dont get... whats the $bp for?
See mysql_query descirption in php manual.

-------------------
Of course the code would look something like this:

Code: Select all

$bp = mysql_connect("localhost","bladegames","****"); 
mysql_select_db("bladegames",$bp); 
mysql_query("UPDATE members SET profile=user, phob=user WHERE here_you_descibe_what_record_has_to_be_updated", $bp);
Please, read the manual.
Post Reply