TheSky Posted May 26, 2011 Share Posted May 26, 2011 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/ Share on other sites More sharing options...
Maq Posted May 26, 2011 Share Posted May 26, 2011 any ideas ? If I had to guess, it's broken somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220636 Share on other sites More sharing options...
TheSky Posted May 26, 2011 Author Share Posted May 26, 2011 on point i dont know how to update mysql database EDIT but is this cutoff valid? Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220637 Share on other sites More sharing options...
Maq Posted May 26, 2011 Share Posted May 26, 2011 on point i dont know how to update mysql database You're already using UPDATE, what's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220638 Share on other sites More sharing options...
fugix Posted May 26, 2011 Share Posted May 26, 2011 your syntax looks correct...did you try troubleshooting your query using mysql_error()? Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220641 Share on other sites More sharing options...
TheSky Posted May 26, 2011 Author Share Posted May 26, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220649 Share on other sites More sharing options...
Maq Posted May 26, 2011 Share Posted May 26, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220656 Share on other sites More sharing options...
TheSky Posted May 26, 2011 Author Share Posted May 26, 2011 UPDATE data SET value1='$value1',value2='$value2',value3='$value3',value4='$value4,value5='$value5' WHERE username='$name' thanks i found now answer for my question Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220682 Share on other sites More sharing options...
Maq Posted May 26, 2011 Share Posted May 26, 2011 UPDATE data SET value1='$value1',value2='$value2',value3='$value3',value4='$value4,value5='$value5' WHERE username='$name' thanks i found now answer for my question In the future you can temporarily use or die(mysql_error()) to display mysql errors. But you should eventually fix/handle them properly. Quote Link to comment https://forums.phpfreaks.com/topic/237539-how-to-update-table/#findComment-1220689 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.