Solarpitch Posted November 24, 2008 Share Posted November 24, 2008 Hey, I have the array $_SESSION['viewed'][]; set up which will store visited products. When I check to see if an id is already in the array it tells me... Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/phone/public_html/view_product.php Why cant they just allow it <?php if(in_array($id, $_SESSION['viewed'])) { //do noting... } else { $_SESSION['viewed'][] = $id ; } ?> Link to comment https://forums.phpfreaks.com/topic/134078-solved-wrong-data-type-issue-with-an-array-session/ Share on other sites More sharing options...
rhodesa Posted November 24, 2008 Share Posted November 24, 2008 if(!is_array($_SESSION['viewed'])) $_SESSION['viewed'] = array(); if(!in_array($id, $_SESSION['viewed'])) $_SESSION['viewed'][] = $id; Link to comment https://forums.phpfreaks.com/topic/134078-solved-wrong-data-type-issue-with-an-array-session/#findComment-697933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.