~n[EO]n~ Posted November 15, 2007 Share Posted November 15, 2007 Hi I am having problem in including a file, I am getting the search type from homepage, it is coming fine. The problem is that I need to include different pages for each type but when i select a different type from homepage the include file is also coming. <?php require_once("config.php"); require_once("user_info.class.php"); // get the info from the search page from homepage $get_type = $_REQUEST['search_cat']; // this first part is working fine....... if ($get_type = 1) { $Admin_type="Artist"; require_once("includes/top_nav.htm"); // this gets loaded require_once("main_search.php"); // this too... echo "Thsi is artistst"; } // when this condition is reached the require_once file above is also loaded elseif ($get_type = 2) { $Admin_type="Distributor"; require_once("hello.php"); // this should load, but it is not loading echo "Thsi is biology"; } elseif ($get_type = 3) { $Admin_type=""; echo "Thsi is online shop"; // same problem here too , it does not echo } else { $Admin_type=""; echo "Thsi is plan"; // same problem here too , it does not echo } $sCurpageurl="search_result.php"; $sSqlQuery=""; $ImageNumber=1; ?> Form code only select box from which the value is passed <select name="search_cat" style="width:205px"> <option value="0">Choose one</option> <option value="1">Artists</option> <option value="2">Distributor</option> <option value="3">Shops</option> <option value="4">Plans</option> </select> Any help please. Thanks Link to comment https://forums.phpfreaks.com/topic/77429-problem-in-including-file/ Share on other sites More sharing options...
trq Posted November 15, 2007 Share Posted November 15, 2007 The comparison operator is == not = if ($get_type == 1) not if ($get_type = 1) Link to comment https://forums.phpfreaks.com/topic/77429-problem-in-including-file/#findComment-391976 Share on other sites More sharing options...
~n[EO]n~ Posted November 15, 2007 Author Share Posted November 15, 2007 , thanks man it worked... Link to comment https://forums.phpfreaks.com/topic/77429-problem-in-including-file/#findComment-391980 Share on other sites More sharing options...
~n[EO]n~ Posted November 15, 2007 Author Share Posted November 15, 2007 The above problem got solved, now I am having another one... The get_type variable is from the index.php page and the form redirects to this page search_result.php (this code) and the search goes on fine with require_once("main_search.php"); . Now in this page there is also a search text box and when i search from this page and redirect to this page, The page comes with error Notice: Undefined index: search_cat in C:\wamp\www\FINAL\search_result.php on line 5 (line 5 is commented below) and it is total blank. Does undefined index also stop other codes from running i.e no other codes are running <?php require_once("config.php"); require_once("user_info.class.php"); // get the info from the search page from homepage $get_type = $_REQUEST['search_cat']; // this line // does the code stops here if the variable $get_type is not found // this first part is working fine....... if ($get_type == 1) { $Admin_type="Artist"; require_once("includes/top_nav.htm"); require_once("main_search.php"); echo "Thsi is artistst"; } elseif ($get_type == 2) { $Admin_type="Distributor"; require_once("hello.php"); echo "Thsi is biology"; } elseif ($get_type == 3) { $Admin_type=""; echo "Thsi is online shop"; } else { $Admin_type=""; echo "Thsi is plan"; } ?> Please someone help... Thanks Link to comment https://forums.phpfreaks.com/topic/77429-problem-in-including-file/#findComment-392069 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.