News:

CPG Release 1.6.28
added submissions from {406man}
cleaned up a few PHP (8.4) deprecations
fixed PHP deprecation in calendar
removed security vulnerability
(please upgrade when possible)

Main Menu

Warning: Invalid argument supplied for foreach()

Started by mwaidmann, October 22, 2003, 12:11:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mwaidmann

i got an error that is driving me crazy. after creating an album there is following error:
Warning: Invalid argument supplied for foreach() in /phpnuke/modules/coppermine/delete.php on line 249

i checked the line and found the array that causes the trouble: $HTTP_POST_VARS['to']

on my local webserver the script runs perfect, the real running webserver shows up with the error. i checked "phpinfo()" to see if there is anything wrong with the server configuration, but it is ok. i got another foreach problem while putting a batch to an album in searchnew.php. again it is a http_post_vars reference!!!

i'm thankful for any help!

maik

gtroll

I had the same problem when I started... I checked the oldboard and no fix was offered but since the function still works and admin is the only one who see the error,it was left as is. I will be sure to test for that in the new version...

mwaidmann

ok. but i need only two users out of the registered who are able to create albums and upload batch files. i thought it would be best changing their status from registered to admin. but if they are admins they can't upload anything because of the described bug. any suggestions what to do?

gtroll

Are you sure the error keeps the uploads from happening- it didn't with me...
It's a "Warning:" not an error.... so it shouldn't stop things up...

mwaidmann

first step todo would be to create an album. after typing in the album title and pressing the submit button, the error shows up. here it ist the $HTTP_POST_VARS['to'] array causing the trouble. if i ignore the warnung and press continue, the new album wasn't created. and without any album i can't upload a batch!
after creating the album manually in phpmyadmin i can upload the batch. at the overview page i can choose the images i want to have in my album. now i click the continue button and the "processing page" shows up. but nothing happens. only the warning is there again. this time in searchnew.php.

mwaidmann

got it.

the problem is caused by an html bug. you use "[]" in the name attribute in input tags which belong to an array in php. i removed it and got the array in two steps working. first collect all values for the array with javascript

function summe(){
 laenge = document.formular.elements.length;
 sammlung = "";
 j = 0;
 for(i=0;i<laenge;i++){
  if(document.formular.elements[i].name == "pics" && document.formular.elements[i].checked){
   sammlung += document.formular.elements[i].value+"|";
  }
  j = i;
 }
document.formular.elements[j].value = sammlung;
}


after this i got a string with all checked images divided by "|".
in searchnew.php i explode the string and got the array.

not as fine as the original but working  :D