I'm building sort of a cms...
The db field that holds the urls has two urls in it at the moment. My challenge right now is just to get the script to tell me whether it finds the url in the database (I'm assuming if it does, my next step is to pass headers to the browser). Any idea what I'm doing wrong here?
The db field that holds the urls has two urls in it at the moment. My challenge right now is just to get the script to tell me whether it finds the url in the database (I'm assuming if it does, my next step is to pass headers to the browser). Any idea what I'm doing wrong here?
PHP:
<?php
$mysqli = new mysqli("localhost", "user", "pw", "db");
if (mysqli_connect_errno()) {
printf("Connection failed: %s\n", mysqli_connect_error());
exit();
} else {
$req_url = $_SERVER['REQUEST_URI'];
echo $req_url;
$sql = "SELECT * FROM ag_pages";
$res = mysqli_query($mysqli, $sql);
if ($res) {
while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$page_url = $newArray['page_url'];
if (in_array($req_url, $page_url)) {
echo "Page Exists";
}
}
} else {
printf ("Could not retrieve records: %s\n", mysqli_error($mysqli));
}
mysqli_free_result($res);
mysqli_close($mysqli);
}
?>