entity_azirius Posted November 3, 2006 Share Posted November 3, 2006 I've recently been making myself a user system for my website, and while making improvements on the current PM system I decided to change the single PM deletion to Single deletion and multiple deletion, now I've got the form worked out and I've got the general gist of what to do, but I still seem to recieve errors, I was just wondering if some one could help me out?REMOVEDAny help on this will be a great help and I will be very greatful for any information/help etc.Thanks Link to comment Share on other sites More sharing options...
shiftJIS Posted November 3, 2006 Share Posted November 3, 2006 Besides the fact that you're only SELECTing fields from the database, not DELETEing them? What sort of error message are you getting? Can't help you much until we know what's going wrong. Link to comment Share on other sites More sharing options...
entity_azirius Posted November 3, 2006 Author Share Posted November 3, 2006 Warning: Invalid argument supplied for foreach() in PMinbox.php on line 262Thats the error warning I recieve.Wow... well I wouldn't of deleted much with that then Thanks for that as well! Link to comment Share on other sites More sharing options...
entity_azirius Posted November 5, 2006 Author Share Posted November 5, 2006 I do hate to double post, but I've still not been able to solve my problem, I've even tried modifying it slightly, tried exploding and imploding the results, but still to no avail!Help would of course be appriciated!Oh, and I'm working with MySQL version 5.0.24 if that makes any difference on the way the MySQL code is written! Link to comment Share on other sites More sharing options...
shiftJIS Posted November 5, 2006 Share Posted November 5, 2006 As such, I can't be of much help. Without line notation, I can't tell whether the snippet you provided contains line 262.If it is, the error message refers to the part of code ("foreach($list as $delete)"). What it means is that $list isn't an Array. It has been defined a few lines earlier as "$list = $_POST['list'];", which I expect is an array. It'll be good to see more of the code regarding the creation of the <form> element and please let me know exactly where line 262 falls. Link to comment Share on other sites More sharing options...
entity_azirius Posted November 5, 2006 Author Share Posted November 5, 2006 Well I've moved the code around since then, that particular line happens to now be 264, this line happens to be:REMOVEDI don't know if that is the information that you are looking for? Link to comment Share on other sites More sharing options...
entity_azirius Posted November 5, 2006 Author Share Posted November 5, 2006 Also it seems instead of splitting it into numbers, its calling them Array... which is really really weird (and not to mention annoying!)! Link to comment Share on other sites More sharing options...
shiftJIS Posted November 5, 2006 Share Posted November 5, 2006 hrm... right BEFORE that "foreach($list as $delete)", add a line that reads: print_r ($list); and post what shows up there. Link to comment Share on other sites More sharing options...
entity_azirius Posted November 5, 2006 Author Share Posted November 5, 2006 It just prints out: Array Link to comment Share on other sites More sharing options...
shiftJIS Posted November 6, 2006 Share Posted November 6, 2006 To tell you the truth, I'm stumped too. I made a mockup of it and it seems to be working. Either see if the other forum members have any idea or I'll need more of the code to be of any help... >_<; Link to comment Share on other sites More sharing options...
entity_azirius Posted November 6, 2006 Author Share Posted November 6, 2006 REMOVEDThat is the whole code... lol Link to comment Share on other sites More sharing options...
shiftJIS Posted November 6, 2006 Share Posted November 6, 2006 Wait, I don't understand... Did you just add this code recently? Because it doesn't quite match what you posted before. You don't need to do a count and split the variable list, because it SHOULD be passed as an Array. $list = $_POST['list']; $sub = $_POST['sub']; if($sub=="true") { if(isset($list)) { echo("<br />\n"); foreach($list as $delete) { //This should work??etc etc Link to comment Share on other sites More sharing options...
entity_azirius Posted November 6, 2006 Author Share Posted November 6, 2006 Ah that must be a recent addition, because they were just attempts at getting things working, I've also tried imploding and exploding as well, and attempting it without counting and exploding/splitting results in the following error (imploding gives an error message also, but a different one):Warning: Invalid argument supplied for foreach() in PMinbox.php on line 265Which I don't understand, it doesn't seem to read the Array correctly or something... :SREMOVEDThat is how it should look by the way!It should all work, but for some reason it doesn't. Its probably something quite simple, but it has me well and truely baffled! Link to comment Share on other sites More sharing options...
jlhaslip Posted November 6, 2006 Share Posted November 6, 2006 if(isset($list) && is_array($list)) { might also echo out some values of the list here. Link to comment Share on other sites More sharing options...
entity_azirius Posted November 6, 2006 Author Share Posted November 6, 2006 Ah, now that I've added that piece of code, it is telling me that it isn't even an array... what happens now? :S This is so confusing! Link to comment Share on other sites More sharing options...
shiftJIS Posted November 6, 2006 Share Posted November 6, 2006 A few questions...Do people browse directly to that page? Or does it get included from another? Is $list used as a variable elsewhere? Does $_POST['list'] get affected by any other code? Is there javascript that might affect the content of the <form> after it reaches the browser?The thing is, I took a few bits of your code, added in some data to fake the mysql connection, and it works fine. You can test it out:http://www.freelancedreams.com/test/test.phpThe source is here:http://www.freelancedreams.com/test/test.txt Link to comment Share on other sites More sharing options...
entity_azirius Posted November 6, 2006 Author Share Posted November 6, 2006 The file is included through another file containing only switches, so no problem there.No Javascript at all, appart from a little on a marquee but nothing that should affect the form.I've even changed the list to PMLIST to make sure, it still considers it as "Array"I don't understand this, its completely stupid! Lol Link to comment Share on other sites More sharing options...
justsomeguy Posted November 6, 2006 Share Posted November 6, 2006 Use this:var_dump($list);View the source, and copy and paste what it says.Also, since list is an array of checkboxes sent through POST, if they do not check any boxes the variable will not be set. Link to comment Share on other sites More sharing options...
entity_azirius Posted November 7, 2006 Author Share Posted November 7, 2006 Heh, well it seems that the problem has been sorted. A function that was used before was messing around with the arrays. Here is what was messing things about! <?php// Clean up MySQL - By Zulumonkeyfunction cleanall() { foreach($_POST as $key => $val) { $_POST[$key] = stripslashes(strip_tags($val, ENT_QUOTES)); $$key = stripslashes(strip_tags($val, ENT_QUOTES)); } foreach($_GET as $key => $val) { $_GET[$key] = stripslashes(strip_tags($val, ENT_QUOTES)); $$key = stripslashes(strip_tags($val, ENT_QUOTES)); }}cleanall();?> But I am not entirely sure why it is not working because of this code, though.Well thank you for all your help on this. It has been much appriciated. Link to comment Share on other sites More sharing options...
shiftJIS Posted November 7, 2006 Share Posted November 7, 2006 No wonder!The reason for this is because the code destroys the array.When "foreach($_POST as $key => $val)" reads $_POST['list'], it sets $key as "list" and $val as the array. However, the next line changes $_POST['list'] to whatever the result you get when you stripslashes and strip_tags from an array. Either it forced it to a string or resulted in a FALSE. Be more careful about these things! >_<; Link to comment Share on other sites More sharing options...
justsomeguy Posted November 7, 2006 Share Posted November 7, 2006 That function should check if the variable is an array, and if it is, either leave it alone or clean each of the elements individually. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now