Kelset Posted November 6, 2006 Share Posted November 6, 2006 Ok i'll just post my code and see what you guys think, here is what I'm trying to do frist.The user log in to the images display page, image for that user is dispalyed and each image has a checkbox with the nameof five. They select the images they would like to keep they hit a form button called "Add Image". This code fires when that button is hit, there is some paging of images and stuff but this is all I think needs to be shown.[code]//Convert session array into easy to use var$sess_five = $_SESSION['five'];//Store checkbox array in var for easy use$five = $_POST['five']; //This will be an array from checkboxes//check to see if any photos have been checked//Get number of checkboxs checkedif (!empty($five)) { //count how many images in each array $five_count = count($five); //loop through each array and see if the value is already stored in it for ($i=0;$i<$five_count;$i++) { if (in_array($five[$i], $sess_five)){ echo " YOU HAVE ONE"; // Just some testing text }else{ //add to session var $sess_five .= $five[$i]; }//End if }//End for}//End if//Store the array back into a session$_SESSION['five'] = $sess_five;[/code]any help would be great!cheers!Stephen Link to comment https://forums.phpfreaks.com/topic/26363-in_array-help/ Share on other sites More sharing options...
AbydosGater Posted November 6, 2006 Share Posted November 6, 2006 This post is a bit vague, well kind of,What exactly do you need help with? Link to comment https://forums.phpfreaks.com/topic/26363-in_array-help/#findComment-120539 Share on other sites More sharing options...
Kelset Posted November 6, 2006 Author Share Posted November 6, 2006 I'm sorry :(Ok the error I'm getting is this.Warning: in_array() [function.in-array]: Wrong datatype for second argument in G:\wamp\www\littlecreations\display.php on line 38Line 38 is if (in_array($five[$i], $sess_five)){any ideas why I'm getting this error? says that it is wrong type but $sess_five is an array as far as I know. I set thesession when they login to be empty $_SESSION['five'] should it be set different way?Thank you for you time in this for meCheers!Stephen Link to comment https://forums.phpfreaks.com/topic/26363-in_array-help/#findComment-120557 Share on other sites More sharing options...
Orio Posted November 6, 2006 Share Posted November 6, 2006 Can you show how $sees_five is defined and changed during the script? It's obviously not an array.Orio. Link to comment https://forums.phpfreaks.com/topic/26363-in_array-help/#findComment-120562 Share on other sites More sharing options...
Kelset Posted November 6, 2006 Author Share Posted November 6, 2006 When they login I have a check user page that sets a bunch of stuff. Once of those things is the session for hold an array.I defined it just by doing this.$_SESSION['five'];Should I do it like this$_SESSION['five'] = array();Thanks for the helpStephen Link to comment https://forums.phpfreaks.com/topic/26363-in_array-help/#findComment-120564 Share on other sites More sharing options...
joshi_v Posted November 7, 2006 Share Posted November 7, 2006 Yes.You should!It will be safe , in case your $sess_five has a single value in it. Link to comment https://forums.phpfreaks.com/topic/26363-in_array-help/#findComment-120894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.