shoutdots Posted August 14, 2007 Share Posted August 14, 2007 hello When iam trying to update a record on the db it update ALL the records their, i don't know where is the erorr ! Here is the action file. $select="UPDATE dir_all SET wbname='$sitename', wbdisc='$sitedisc', wblink='$sitelink' WHERE id='$id'"; mysql_query($select) or die($select); ?> Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/ Share on other sites More sharing options...
rlindauer Posted August 14, 2007 Share Posted August 14, 2007 Try using the mysql_error() function to see what the actual problem is: <?php $select="UPDATE dir_all SET wbname='$sitename', wbdisc='$sitedisc', wblink='$sitelink' WHERE id='$id'"; mysql_query($select) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324128 Share on other sites More sharing options...
shoutdots Posted August 14, 2007 Author Share Posted August 14, 2007 There is no error in the code, its a logical error i think Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324129 Share on other sites More sharing options...
rlindauer Posted August 15, 2007 Share Posted August 15, 2007 Where is $id being defined? Maybe if you posted more code we could see what is going on. Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324147 Share on other sites More sharing options...
shoutdots Posted August 15, 2007 Author Share Posted August 15, 2007 I have post the $id into another file called editdel.php, i know it doesn't make any sense to put the $id into the last code, but it works when i make a button for delete. <? //Delete.php $del="DELETE FROM dir_all WHERE id='$id'"; //edit_action.php $update="UPDATE dir_all SET wbname='$sitename', wbdisc='$sitedisc', wblink='$sitelink' WHERE id='$id'"; mysql_query($update) or die(error); //editdel.php <td bgcolor="#FBFBFB"><div align="center"><span class="style4"><span class="style4"></span></span><a href="edit_site.php?id=<? echo $row['id']; ?>">Edit</a></div></td> <td bgcolor="#FBFBFB"><div align="center"><span class="style4"><span class="style4"></span></span><a href="delete.php?id=<? echo $row['id']; ?>">Delete</a></div></td> may be the problem that the ?id= doesn't refer directly to edit_action.php, first its going to edit_site.php file . if this is true, how can i solve this problem ! Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324154 Share on other sites More sharing options...
rameshfaj Posted August 15, 2007 Share Posted August 15, 2007 IT seems that the query is ok.But if u are frequntly getting the problem,then repair the table using flush() command. I too had the problem,in my case the new update affects some values of already existing data.But when I created the new table, the problem was ok.As far as I am concerned it is ok now. Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324332 Share on other sites More sharing options...
Fadion Posted August 15, 2007 Share Posted August 15, 2007 Dont know if flush or repair or whatever will fix your problem, but from what i can see the only logical thing is that id isnt getting any value, but u should have a syntax error i guess. Try echoing $id before making the query to check if its getting a value. Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324340 Share on other sites More sharing options...
shoutdots Posted August 15, 2007 Author Share Posted August 15, 2007 repairing didn't make anything , and when i tried to echo $id it doesn't give any value. Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324451 Share on other sites More sharing options...
shoutdots Posted August 15, 2007 Author Share Posted August 15, 2007 someone help please ! Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324479 Share on other sites More sharing options...
rotto Posted August 15, 2007 Share Posted August 15, 2007 I dont think $id should be in '' tags because it is an integer not a string. (It should be "WHERE id = $id" not "WHERE id = '$id'" ) Quote Link to comment https://forums.phpfreaks.com/topic/64953-update-data-problem/#findComment-324489 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.