Forum Moderators: coopster
The problem is that it always outputs the 404, regardless of whether or not there's a matching record in the db. I guess something must be wrong with the script but I can't see what:
This is the code:
<?php
include ('manager/exhibitions/inc/dbconnect.php');
$query = "SELECT showname FROM exhibitionstable WHERE showname = '". mysql_real_escape_string($_SERVER['REQUEST_URI']) ."' ";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
echo "<p>404 error</p>";
}
else
{
header('location: exhibitions.html');
exit;
}
?>
Any ideas?
"SELECT showname FROM exhibitionstable WHERE showname = '". mysql_real_escape_string($_SERVER['REQUEST_URI']) ."'"; Also try adding "or die(mysql_error())" as follows:
$numresults = mysql_query($query) or die(mysql_error());
SELECT showname FROM exhibitionstable WHERE showname = 'fixed.htc'
This is the code:
<?php
include ('manager/exhibitions/inc/dbconnect.php');
$name = basename($_SERVER['REQUEST_URI']);
if(false!==strpos($name,'?'))
{
$name = substr($name,0,strpos($name,'?'));
}
$query = "SELECT showname FROM exhibitionstable WHERE showname = '". mysql_real_escape_string($name) ."' ";
echo $query;
$numresults=mysql_query($query) or die(mysql_error());
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
echo "<p>404 error</p>";
}
else
{
header('location: exhibitions.html');
exit;
}
?>
What's interesting if that it worked ONCE, I typed in [mydomain...] and travejl.html is an entry in the db) and it forwarded to exhibitions.html.
But now it just shows the output as above...
You can use the "Live HTTP Headers" add-on for Firefox/Mozilla browsers or a similar add-on to verify this.
Also be sure that for any 'good' URL, the server outputs only a single response, and not a 404 followed by a 301. These responses need to match the HTTP protocol requirements, or your search rankings will very likely suffer.
Jim