cooldude832 Posted July 17, 2007 Share Posted July 17, 2007 I have a page that lets me change some search criteria to different types. You can see it at http://www.americandreamhorses.com/search.php It works great if you change the criteria type ( its a form separate from search), but if you submit the search form all the criteria dissapears. Anyone got any ideas. This is what i'm trying right now. <?php session_start(); if(!empty($_GET['adcrt'])){ $_SESSION['adcrt'] = $_GET['adcrt']; } if(empty($_SESSION['adcrt'])){ $_SESSION['adcrt'] = "horse"; } //then the echo part is a switch switch ($_SESSION['adcrt']){ case "horse": echo $search['horse']; break; case "pet": echo $search['pet']; break; case "trailer": echo $search['trailer']; break; case "tack": echo $search['tack']; break; case "apparel": echo $search['apparel']; break; case "saddle": echo $search['saddle']; break; default: echo $search['horse']; } ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 and whats strange is I can get it to echo out $_SESSION['adctr'] and it looks right but not echo out $searchcritera[$_SESSION['adctr']] (using the switch I made) Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 dude try this <?php session_start(); if(isset($_SESSION['adcrt'])){ $_SESSION['adcrt'] = "horse"; } //then the echo part is a switch switch ($_SESSION['adcrt']){ case "horse": echo $search['horse']; break; case "pet": echo $search['pet']; break; case "trailer": echo $search['trailer']; break; case "tack": echo $search['tack']; break; case "apparel": echo $search['apparel']; break; case "saddle": echo $search['saddle']; break; default: echo $search['horse']; } ?> <?php //better session_start(); if(isset($_SESSION['adcrt'])){ echo $search[$_SESSION['adcrt']]; } else{ echo $search['horse']; } ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 that ain't gonna work, because it doesn't set the session, my issue isn't that for some stupid reason it won't echo out the variables $search['pet'] or $search['trailer'], etc etc if that second form is submitted even though it will echo out $_SESSION['adctr'] as you can see with: <?php <?php require('includes/search_critera.php'); switch ($_SESSION['adcrt']){ case "horse": echo $search['horse']; echo $_SESSION['adcrt']; break; case "pet": echo $search['pet']; echo $_SESSION['adcrt']; break; case "trailer": echo $search['trailer']; echo $_SESSION['adcrt']; break; case "tack": echo $search['tack']; echo $_SESSION['adcrt']; break; case "apparel": echo $search['apparel']; echo $_SESSION['adcrt']; break; case "saddle": echo $search['saddle']; echo $_SESSION['adcrt']; break; default: echo $search['horse']; echo $_SESSION['adcrt']; } ?> Its getting me really mad cause it doesn't make sense Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 dude check echo $search['horse']; echo $_SESSION['adcrt']; can i see this array $search and the setting of this $_SESSION['adcrt']=??? maybe no echo because no value at all Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 it works fine in one case and not another the array is huge. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 it works fine? where in the case of horse? if that so then the session array if the prob Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 i think i've got it worked out now, I'm using includes I think my issue was that when the other form was set I had a var called $search in the doc thus it deleted my array but its good now. I hate stupid issues like that Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 dude tip if u think u have the error on some array always use print_r() or var dump it helps me fast to debug Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 Do i have to declare session_start(); pre the doc type for sessions to register? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 Do i have to declare session_start(); pre the doc type for sessions to register? what? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 17, 2007 Author Share Posted July 17, 2007 do i have to have <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> or can i have <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start(); ?> Version B failed and Version A works, But Version A is not xhtml 1.6 stricness Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 17, 2007 Share Posted July 17, 2007 i dont think it affect that version thing your talking Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.