php? Posted January 2, 2008 Share Posted January 2, 2008 Okay so according to the code below when I press accept it should update the field "Active" to 1 and then send it to a different table and delete it from the old table. Well it won't update the value of active to 1. It sends and everything, but the Active stays to 0. No errors are given. foreach($_POST['row_s'] as $key => $val){ $info = mysql_fetch_array(mysql_query("SELECT * FROM pending WHERE ID='".$key."'")); if($val == 1) { echo "{$info['Username']} is being accepted..."; [b]$update = mysql_query("UPDATE pending SET Active=1 WHERE ID='".$key."'") or die(mysql_error());[/b] mysql_query("INSERT INTO accepted SET Username='".$info['Username']."', Password='".$info['Password']."', Email='".$info['Email']."'"); // Moves user to new table echo "done <br>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/ Share on other sites More sharing options...
php? Posted January 2, 2008 Author Share Posted January 2, 2008 It seems like it should update... and there are no errors, so hmm Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428741 Share on other sites More sharing options...
teng84 Posted January 2, 2008 Share Posted January 2, 2008 i dont see anything wrong with your update statement.. maybe try to pint your update query and paste it manually on your db to see whats gonna happen! Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428744 Share on other sites More sharing options...
revraz Posted January 2, 2008 Share Posted January 2, 2008 Fieldname set right and is it set to INT? Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428746 Share on other sites More sharing options...
php? Posted January 2, 2008 Author Share Posted January 2, 2008 mhm Heres my set up... CREATE TABLE `pending` ( `ID` int(11) NOT NULL auto_increment, `Username` varchar(255) NOT NULL, `Password` varchar(255) NOT NULL, `Email` varchar(255) NOT NULL, `Active` int(11) NOT NULL default '0', `Level_access` int(11) NOT NULL default '2', PRIMARY KEY (`ID`), UNIQUE KEY `Username` (`Username`), UNIQUE KEY `Email` (`Email`) ) ENGINE=MyISAM; Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428767 Share on other sites More sharing options...
trq Posted January 2, 2008 Share Posted January 2, 2008 Once again. Why do you need to seperate tables (pending and accepted) for this? While I'm at it.... how many topics do you plan on creating to get this resolved? Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428769 Share on other sites More sharing options...
php? Posted January 2, 2008 Author Share Posted January 2, 2008 Thorpe this doesn't really have anything to do with the seperation of the tables. Yes I could do what you suggested before but it wouldn't solve this. In fact I would have to do almost the same thing. And every topic that ive posted have been solved and were different issues. I'm just adding different parts into the script. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428771 Share on other sites More sharing options...
trq Posted January 2, 2008 Share Posted January 2, 2008 this doesn't really have anything to do with the seperation of the tables. Yes I could do what you suggested before but it wouldn't solve this Maybe not, but it would be a better design. And every topic that ive posted have been solved and were different issues. I'm just adding different parts into the script. Just a word of caution. Alot of your topics have been so closely related that they could all go within the same thread. Obviously your solutions have not been sufficient thus far. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428787 Share on other sites More sharing options...
php? Posted January 2, 2008 Author Share Posted January 2, 2008 Last time I posted a lot combined someone said I should seperate them so people don't get bored... just following suggestions. Besides it's not very appealing to read through many old comments to find out that that particular problem was solved. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428799 Share on other sites More sharing options...
php? Posted January 3, 2008 Author Share Posted January 3, 2008 Doesn't list any errors in Notepad++ eiter Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428839 Share on other sites More sharing options...
trq Posted January 3, 2008 Share Posted January 3, 2008 the code below when I press accept it should update the field "Active" to 1 and then send it to a different table and delete it from the old table What is the point in updating Active to 1 in the pending table if you are planning on removing it all together? I just don't follow your logic at all. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428861 Share on other sites More sharing options...
php? Posted January 3, 2008 Author Share Posted January 3, 2008 I never said that I was going to remove anything. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428942 Share on other sites More sharing options...
php? Posted January 3, 2008 Author Share Posted January 3, 2008 Could someone who actually wants to help and not criticize read this? Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428944 Share on other sites More sharing options...
teng84 Posted January 3, 2008 Share Posted January 3, 2008 heres what you should do to debug.. first echo something inside that condition to know if the statement inside that condition is being read echo your query and run it manually in your db create an update statement in you DB(phpmysql if you use that) and copy the working code to see where you went wrong.. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428947 Share on other sites More sharing options...
awpti Posted January 3, 2008 Share Posted January 3, 2008 Criticism; Your table layout is attrocious. Follow the simple principles of Relational Database Design 2.) Do you have any error output? 3.) What happens when you issue the query (queries?) directly? 4.) Some cleaner code for you: foreach($_POST['row_s'] as $key => $val){ $res = mysql_query("SELECT Username, Password, Email FROM pending WHERE ID = '{$key}'") $info = mysql_fetch_array($res); if($val == 1) { echo "{$info['Username']} is being accepted..."; mysql_query("UPDATE pending SET Active = 1 WHERE ID = '{$key}'") or die(mysql_error()); mysql_query("INSERT INTO accepted SET Username='{$info['Username']}', Password='{$info['Password']}', Email='{$info['Email']}'"); // Moves user to new table echo "done <br />\n"; Using a second table to 'activate' users is just.. well. Dumb design. And a total, pointless waste of time. You're updating a table, then copying the data to a, most likely match, table with only 1 field modified (Active). Fix your logic and people may be more willing to help. Bad logic dictates bad code (check out thedailywtf.com for good examples of what NOT to do). Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428951 Share on other sites More sharing options...
awpti Posted January 3, 2008 Share Posted January 3, 2008 And this is why you don't get help. Great attitude, buddy. You are free to not listen to the developer with 10 years of experience. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428998 Share on other sites More sharing options...
php? Posted January 3, 2008 Author Share Posted January 3, 2008 I believe I asked people to look at this who helped not criticize. In other words I never asked for your help, nor your comments. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-428999 Share on other sites More sharing options...
teng84 Posted January 3, 2008 Share Posted January 3, 2008 Im about to shut down my pc and go home but this tread is going no where.. TO php? i understand his felling frustration about the work... when you fell like your mind stop functioning you need help not critics.. he cant solved the prob everybody is saying that his logic is wrong but maybe php? doesnt want to edit his code simply because he doesnt want to encounter another problem.. this message by php? should be understandable by yopu guys IM NOT native english bu i do UNDERSTAND THIS Could someone who actually wants to help and not criticize read this? for those who said that his coding and logic is wrong then you should correct it.. i was actually planning to rewrite this but i have go home office time is over.. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-429004 Share on other sites More sharing options...
awpti Posted January 3, 2008 Share Posted January 3, 2008 Note that I did, in fact, throw some pointers his way. Without understand the logic (???) of this application, there is really no way anyone can help him. I cleaned up his code a bit (readability for the win). But that's about all I can actually do without seeing: Table layout. More code. Understanding of the 'logic' behind this. You don't become a better developer by avoiding criticism. You become a better developer by getting criticism, accepting it and adjusting your model accordingly. I'll always criticize code, especially if they tell me not to. That's a giant, flashing red light right there. Avoiding problems by creating more is the worst thing that can be done. Fix the problems before they present themselves and life is much, much easier. Maintaining a broken codebase and bad logic is hard. I've been there and done that. I asked him for error output, what happens when he tries it at the console (or via phpMyAdmin), etc. He was told how to correct his logic. He isn't paying me to write his code, but I'm willing to help him make it work well and be easy to maintain in the future. Even with his boo-hoo tirade, I'm still willing to help if he's willing to provide more information. Quote Link to comment https://forums.phpfreaks.com/topic/84197-solved-not-updating/#findComment-429007 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.