My goal: compare the actual url to a stored url in MySQL DB. If there's a match the page title and meta description info is loaded from the DB into the fields on the page.
Problem: I need to remove the query string so the url is clean for the comparison.
The existing code works for the main pages that list the blogs/lessons/etc, but when I go to page 2, 3, 4, etc the query string breaks the comparison.
In the code you will see $actual_link - that needs to have the query string removed and that is what I have yet to find a solution that actually works, as for what I've tried, there have been too many iterations to remember them.
Server Info: PHP 7.3.17; MySQL MariaDB-10.2.32; Apache-2.4.43/
$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$sql = "SELECT * FROM meta WHERE siteLink = '$actual_link'";
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
?>
<?php include_once "myHead.php"; ?>
<title><?php echo $row["title"]; ?></title>
<meta name="description" content="<?php echo $row["meta_desc_content"]; ?>">
<?php
}
}
else
{
echo "Shit, it ain't working.";
}
?>