Answer the question
In order to leave comments, you need to log in
Why is my code not working?
I'm making a mobile version, and redirecting to mobile devices, respectively, I found the mobile detect php library, I sort of sewed it in correctly
<?
include 'mdetect/Mobile_Detect.php';
$detect = new Mobile_Detect;
$useurl = '';
if ( $detect->isMobile() ) {
global $DB;
$err_mess = "<br /> err<br />";
$url = $_SERVER['REQUEST_URI'];
$results = $DB->Query("SELECT * FROM b_url_redirect_forge", false, $err_mess.__LINE__);
if($results){
while ($row = $results->Fetch())
{
switch ($url){
case $row['f_url'] or "/news/*" or "/offers/*" :
$trueurl = $DB->Query("SELECT `m_url` FROM `b_url_redirect_forge` WHERE f_url='".$url."' ");
$tu = $trueurl->Fetch();
$useurl = $tu;
header('Location: mobileurl'.$tu['m_url'].'');
exit();
break;
default :
header('Location: 'mobileurl' ');
exit();
break;
}
}
}else{
echo 'No matches';
};
}
?>
Answer the question
In order to leave comments, you need to log in
header('Location: "mobileurl'.$tu['m_url'].'"');
//...
header('Location: "mobileurl" ');
$results->Fetch() - what do you want to get with this?
Should be $result->fetch_assoc() or fetch_row()
depending on what array you want to get
header('Location: mobileurl'.$tu['m_url'].'');
what is mobileurl?? (the link must be either http:// or on the same server /xxx )
header(' Location: xxxx.ru '. $tu['m_url'] ); - should be like this
header(' Location: xxxx.ru '); - it should be like this
if you have url in a variable then just write 'Location' . $url
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question