} // this code for check extra characters at the end of city if exits than redirect to 404 page // Improved validation that handles multi-word cities like "Sydney, New South Wales" // Convert city name to URL format for comparison $cityUrlFormat = strtolower(trim(str_replace([' ', ','], ['-', ''], $city_nameURL))); $urlSlug = strtolower(trim($paras[3])); // Check if the city name appears at the end of the URL slug // This handles cases where course name comes before city name if (substr($urlSlug, -strlen($cityUrlFormat)) !== $cityUrlFormat) { header("Location: /404.php?extra_char_at_end_city"); exit; } // Fetch course name from the database using the sanitized course ID. $qcc = mysqli_query($conn, "SELECT * FROM main_menu_course WHERE course_name = '$course_nameURL'"); $rw33 = mysqli_fetch_assoc($qcc); $course_name_from_url = $rw33 ? $rw33['course_name'] : 'Unknown Course'; // Use a fallback value if course not found. $course_id_from_url = $rw33 ? $rw33['id'] : ''; //this $_SESSION['ses_course_name'] variable will use on this page- workshop-dates.php if($course_name_from_url){ $_SESSION['ses_course_name']=$course_name_from_url; } if ($course_name_from_url == "Unknown Course") { header('Location: https://www.icertglobal.com/404.php?no_course1'); exit(); // Always exit after a header redirect. } if (strtolower(str_replace(' ', '-', $rw33['domain_name'])) != $paras[1]) { header('Location: https://www.icertglobal.com/404.php?course_dmn_fl'); exit(); // Always exit after a header redirect. } //url keywords after course name and database url_keyword both are matched otherwise redirect to 404 page $words = explode('-', strtolower($paras[2])); $cursename_res = str_replace('-', ' ', $paras[2]); $check_courseN=trim($course_name_from_url).' '.$rw33['url_keyword']; if ($rw33['url_keyword']!="") { if(strtolower($check_courseN)!=$cursename_res) { header('Location: https://www.icertglobal.com/404.php?keyword_not_matched2'); exit(); // Always exit after a header redirect. } }elseif($rw33['url_keyword']==""){ //if url_keyword blank than do nothing if(strtolower(str_replace('-', ' ',$course_name_from_url))!=$cursename_res) { header('Location: https://www.icertglobal.com/404.php?keyword_not_matched'); exit(); // Always exit after a header redirect. } } elseif (!in_array(strtolower($rw33['url_keyword']), $words)) { header('Location: https://www.icertglobal.com/404.php?course_keyword_nf'); exit(); // Always exit after a header redirect. } // Fetch city name and details from the database using the sanitized city ID. $q9966 = mysqli_query($conn, "SELECT * FROM subcategory WHERE subcategory = '$city_nameURL'"); $rw366 = mysqli_fetch_assoc($q9966); $citynumcount = mysqli_num_rows($q9966); $city_name_from_url = $rw366 ? $rw366['subcategory'] : 'Unknown City'; // Use a fallback value if city not found. // If a valid city was found in the URL, update the user's session with the correct country and city. if ($citynumcount > 0) { $safe_cat_id = mysqli_real_escape_string($conn, $rw366['cat_id']); $q6600 = mysqli_query($conn, "SELECT * FROM countries WHERE id = '{$safe_cat_id}'") or die(mysqli_error($conn)); $n6600 = mysqli_fetch_assoc($q6600); // Set session variables to be used throughout the site. if ($n6600) { $_SESSION['ses_country_id'] = $rw366['cat_id']; $_SESSION['sess_country_name'] = $n6600['country_name']; $_SESSION['ses_city_name'] = $city_name_from_url; } }else { //if city correct city is not found than redirect to 404 page header('Location: https://www.icertglobal.com/404.php?url_city_ntf'); exit(); // Always exit after a header redirect. } // Get country details from the session to use in page titles and metadata. $country_id = isset($_SESSION['ses_country_id']) ? $_SESSION['ses_country_id'] : 1; // Default to 1 (USA) if not set. $safe_country_id = mysqli_real_escape_string($conn, $country_id); $query44 = mysqli_query($conn, "SELECT country_name FROM countries WHERE id = '{$safe_country_id}'") or die(mysqli_error($conn)); $row44 = mysqli_fetch_array($query44); $country_name_title = $row44 ? $row44['country_name'] : 'Global'; // Fallback for title. // main query for check if course and city name is exits in db table than execut if condition $qcc667 = mysqli_query($conn, "SELECT id FROM new_course_content WHERE course_name = '$course_name_from_url' and city_name='$city_name_from_url' "); $rowcount= mysqli_num_rows($qcc667); if ($rowcount>0) { $qcc66 = mysqli_query($conn, "SELECT * FROM new_course_content WHERE course_name = '$course_name_from_url' and city_name='$city_name_from_url'"); }else{ $qcc66 = mysqli_query($conn, "SELECT * FROM new_course_content WHERE course_name = '$course_name_from_url'"); } $course_content = mysqli_fetch_assoc($qcc66); $qcc6688 = mysqli_query($conn, "SELECT * FROM course_with_city_list WHERE course = '$course_name_from_url' and city='$city_name_from_url' "); $course_city_content = mysqli_fetch_assoc($qcc6688); ?>
Warning: Undefined variable $conn in /home/icertglo/public_html/course_v25.php on line 130

Warning: Undefined variable $course_name_from_url in /home/icertglo/public_html/course_v25.php on line 130

Fatal error: Uncaught TypeError: mysqli_real_escape_string(): Argument #1 ($mysql) must be of type mysqli, null given in /home/icertglo/public_html/course_v25.php:130 Stack trace: #0 /home/icertglo/public_html/course_v25.php(130): mysqli_real_escape_string(NULL, NULL) #1 {main} thrown in /home/icertglo/public_html/course_v25.php on line 130