Jump to content

Arrays, Forms etc Problems


entity_azirius

Recommended Posts

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

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

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

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

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...