beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 EDIT : It sort of works. The code changed the value but only after mine is changed my code is : the $on['id'] value is set in the script. Via $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY 'id' DESC ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) The form code is : <form action=\"update.php\" method=\"post\"> <input type=\"hidden\" name=\"id\" value=\"".$on['id']."\"><input type=\"text\" name=\"game_show\" value=\"".$info['game_show']."\" size=\"1\"> <input type=submit value=update> The update script is : <?php include("connect.php"); $id=$_POST['id']; $game_show=$_POST['game_show']; $query="UPDATE members SET game_show='$game_show' WHERE id=$id"; mysql_query($query); echo "Record Updated <a href=mem.php>MEM</a>"; mysql_close(); ?> I mean the code updates the data but only if i update mine first and i am readig up on GET & POST Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433375 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 what do you mean by update mine first Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433394 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 if i go to change the form from say yes to no, you get the update sucsessful msg, but doesnt change anything in the db, but if i update mine first id 1, i get the update sucsefful msg then if i update next one it works. its like will only let me update them in id order. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433413 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 That is werid. In your update script try echoing out $ID and see what the result is every time. Also add error_reporting(E_ALL); to the top of the pages. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433417 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 echo $id; echos the correct id of the member i am changing. & i dont get a error on the page. i am lost. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433420 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 try this <?php include("connect.php"); $id=$_POST['id']; $game_show=$_POST['game_show']; $query="UPDATE members SET game_show='$game_show' WHERE id='$id'"; mysql_query($query); echo "Record Updated <a href=mem.php>MEM</a>"; mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433425 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 No, will still only update the script in order of id. Ie mine (id1) account 2 (id2) i have no idea could it be some thing in the form i wounder? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433428 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 add in an sql error on the update page. or die(mysql_error() If the correct id is showing each time regardless of which one is edited then the correct id should be updated. This is strange Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433430 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 mysql_query($query) or die(mysql_error()); Runs with no errors and i added a second echo echo $id; echo $game_show; They both display the correct result. but doesnt update in the database. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433432 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 i took the ORDER BY id, DESC out the mysql querry and it is working now ??? ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433438 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 that really should affect it. This is odd. Do you need that statement in? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433439 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 i had this code : $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ORDER BY id DESC ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) changed it to this : $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) and it works fine now. EDIT : Doesnt work it has reversed the order ie : will only let me change id2 then id 1 etc... Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433440 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 Try this change $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) too $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) { $id = $on['id']} then change <form action=\"update.php\" method=\"post\"> <input type=\"hidden\" name=\"id\" value=\"".$on['id']."\"><input type=\"text\" name=\"game_show\" value=\"".$info['game_show']."\" size=\"1\"> <input type=submit value=update> to <form action=\"update.php\" method=\"post\"> <input type=\"hidden\" name=\"id\" value=\"".$id."\"><input type=\"text\" name=\"game_show\" value=\"".$info['game_show']."\" size=\"1\"> <input type=submit value=update> Failing that we can set the url to contain the id. Then use the url to update the database. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433445 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 No dont work, Its reversed - like updates id 3 then 2 then 1 im totally lost here ??? ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433449 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 i have no idea. The variable names are unique? This is really werid. If the $id is echoed out correctly on the update.php page then thats what your query should be doing. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433451 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 variable name id and game_show. i have no idea. you need to see any more of the script of anything? i hast me i can update it but only id DESC or ASC not like any order i want. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433452 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 You should be able to order in any order regardless. You are upadting by Id number. Show all code Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433464 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 if($_GET[action] == 'update_off' ) { //second level security if($info[security] <= '7' ) { $page_to_view = " Tried to view who has update off. "; echo " <br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; $sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id']. "', '" . $page_to_view . "', '$info[ip]')"; if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error()); } } else { echo " <form action=\"update.php\" method=\"post\"><br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>. <br />"; echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>"; $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) { $id = $on['id']; echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><input type=\"hidden\" name=\"id\" value=\" ".$id." \"><input type=\"text\" name=\"game_show\" value=\"".$on['game_show']." \" size=\"1\"> <input type=submit value=update></td></table>"; } echo "<br /><br /> $space <a href=mem.php>Finished</a> "; } update.php is as followed. <?php include("connect.php"); $id=$_POST['id']; $game_show=$_POST['game_show']; $query="UPDATE members SET game_show='$game_show' WHERE id='$id'"; mysql_query($query) or die(mysql_error()); echo "Record Updated <a href=mem.php>MEM</a>"; echo " the is you changed was ".$id." "; mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433467 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 update.php <?php include("connect.php"); $id=$_POST['id']; $game_show=$_POST['game_show']; mysql_query("UPDATE members SET game_show = '$games_show' WHERE id = '$id' ") or die(mysql_error()); echo "Record Updated <a href=mem.php>MEM</a>"; echo " the id you changed was ".$id." "; mysql_close(); ?> The rest if($_GET[action] == 'update_off' ) { //second level security if($info[security] <= '7' ) { $page_to_view = " Tried to view who has update off. "; echo " <br /><br />$space<span style=\"color: orange\"> <strong>Unable to view this page. Level 7 security or higher required. This action has been logged.<strong></span> "; $sql = "INSERT INTO `logged_1` (`id`, `username`, `player_id`, `page_to_view`, `ip_address`) VALUES ('','" . $info['username'] . "', '" .$info['id']. "', '" . $page_to_view . "', '$info[ip]')"; if ( !$result = mysql_query($sql) ) { die('MySQL Error: ' . mysql_error()); } } else { echo " <form action=\"update.php\" method=\"post\"><br /> <br /> $space This is all game members who have the update messages turned <strong>off</strong>. <br />"; echo " $space <table width=\"50%\"> <td width=\"15%\">$space <u>Username</u></td> <td width=\"10%\"><u>Game Id</u></td> <td width=\"15%\"><u>Action</u></td> <td width=\"15%\"><u>Change</u></td></table>"; $get_on = mysql_query(sprintf("SELECT * FROM `members` WHERE game_show='N' ")) or die('Error: ' . mysql_error()); while($on = mysql_fetch_array($get_on)) { echo " <table width=\"50%\"> <td width=\"15%\"> $space <a href=\"view.php?\">" .$on['username']. "</a></td> <td width=\"10%\">" .$on['id']. "</td><td width=\"15%\">Contact</a></td><td width=\"15%\"><input type=\"hidden\" name=\"id\" value=\" ".$on['id']." \"><input type=\"text\" name=\"game_show\" value=\"".$on['game_show']." \" size=\"1\"> <input type=submit value=update></td></table>"; } echo "<br /><br /> $space <a href=mem.php>Finished</a> "; } Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433477 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 Now all it does is if i edit id 2 value to "Y" and click update on the up date page is updates the next value say have 4 id 1 2 3 4 it will satart at four then if i click edit on 1 it will do 3 if you understand what im saying. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433483 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 that is strange. try and create an update script that doesn't rely on any variable and you manually set the information <?php include("connect.php"); mysql_query("UPDATE members SET game_show = 'Y' WHERE id = '2' ") or die(mysql_error()); echo "updated"; mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433486 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 did that actually in mysql and it worked. and created a script and it worked. So i have no idea why its not working Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433490 Share on other sites More sharing options...
adam291086 Posted January 8, 2008 Share Posted January 8, 2008 Well lets build on that script slowly and it will help locate the problem Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433539 Share on other sites More sharing options...
beansandsausages Posted January 8, 2008 Author Share Posted January 8, 2008 i have tried several things and cant seem to get it to work, it will update in a desc order but not in a random order Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433542 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 did that actually in mysql and it worked. and created a script and it worked. So i have no idea why its not working That makes no sense. I think I mentioned this on my previous post. What's $info[security]? I don't see that defined anywhere. I think it should also be $info['security']. Quote Link to comment https://forums.phpfreaks.com/topic/84861-problems-problems/page/2/#findComment-433545 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.