Bisa Posted December 3, 2008 Share Posted December 3, 2008 I'm trying to update some rows in my db using this query in a while-loop mysql_query('UPDATE eqdkp_members SET member_attendance = ' . $percent_of_raids . ' WHERE member_name = ' . $row['member_name'] . ''); To make sure I'm having variables n' stuff sorted I entered this echo: echo $row['member_name'] . ' - ' . $percent_of_raids . '<br />'; which gives me the following output: User1 - 60 User2 - 40 User3 - 8 User4 - 99 As you can see the $row['member_name'] and $percent_of_raids change accordingly throughout the while-loop but if I check my database the same old default values are still there, no updates have been made (and Mind you I do get the $row['member_name'] from the same database ) Any help would be appreciated :-\ Quote Link to comment https://forums.phpfreaks.com/topic/135371-solved-my-update-fails/ Share on other sites More sharing options...
Maq Posted December 3, 2008 Share Posted December 3, 2008 You can do this multiple ways. But the easiest for me would be to use the double quotes for the entire string and single quotes for the strings that you're updating. Of course you could escape but I personally don't like to do that. If you put {} around arrays it won't cause any errors in your string. I haven't tested this: mysql_query("UPDATE eqdkp_members SET member_attendance = '" . $percent_of_raids . "' WHERE member_name = '" . {$row['member_name']} . "'") or die (mysql_error()); side note: Try debugging sql statements by using the or die (mysql_error()); at the end. I bet if you put this at the end of your current query it will throw an error... Quote Link to comment https://forums.phpfreaks.com/topic/135371-solved-my-update-fails/#findComment-705108 Share on other sites More sharing options...
Bisa Posted December 3, 2008 Author Share Posted December 3, 2008 Cheers, works as intended Quote Link to comment https://forums.phpfreaks.com/topic/135371-solved-my-update-fails/#findComment-705112 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.