Jump to content

how to update table


TheSky

Recommended Posts

hey forum people

can you help me on one problem so i have script what should update mysql table by username

UPDATE data SET username='$name' WHERE value1='$value1' AND value2='$value2' AND value3='$value3' AND value4='$value4' AND value5='$value5'

any ideas ?

Link to comment
Share on other sites

do i have to select database also ? i think i do and i didnt add it i did run $result = mysql_query($sql) or die(mysql_error()); and it was successful

EDIT: hmm i checked i have selected in included connect file but i think i made wrong ?

i want update username and add data

Link to comment
Share on other sites

do i have to select database also ?

Yes, how else would your program know the BD to use?

 

i think i do and i didnt add it i did run $result = mysql_query($sql) or die(mysql_error()); and it was successful

mysql_query is what actually executes your query.  Read the documentation...

Link to comment
Share on other sites

UPDATE data SET value1='$value1',value2='$value2',value3='$value3',value4='$value4,value5='$value5' WHERE username='$name'

thanks i found now answer for my question :P

In the future you can temporarily use or die(mysql_error()) to display mysql errors.  But you should eventually fix/handle them properly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.