Jump to content

If and Else


iceblox

Recommended Posts

Guys,

 

THis is a selection of code from by script. This is the only bit ive changed so there must be something wrong this bit.. Can anyone see anything wrong?

 

 

if($checkurl!=$endurl)
{
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: $checkurl"); 
exit(); 
}
else 
{

header("HTTP/1.1 301 Moved Permanently"); 
header("Location: Domain.com"); 
exit(); 
}

Link to comment
https://forums.phpfreaks.com/topic/62717-if-and-else/
Share on other sites

Hmm ok maybe if i post the whole script.

 

 

<?php

$connection = mysql_connect('localhost','user','pass');

mysql_select_db('databasename');

$query = "SELECT * FROM Makes WHERE MakeID=" . $_GET['MakeID'] . " AND MakeActive = '1'";
   
$result = mysql_query($query);

$page = mysql_fetch_row($result);

$make = ereg_replace (" ", "-", $page[1]);
$pageurl = "$make-Cars-$page[0].html";

$endurl = $_SERVER['REQUEST_URI'];
$checkurl="http://www.domain.com/$pageurl";

//echo"arturl $checkurl<br />endurl $endurl<br />";
$endurl = stripslashes($endurl);
$endurl= "http://www.domain.com$endurl";
$endurl=trim($endurl);
$checkurl=trim($checkurl);

if($checkurl!=$endurl)
{
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: $checkurl"); 
exit(); 
}
else
{
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: domain.com"); 
exit(); 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/62717-if-and-else/#findComment-312183
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.