Jump to content

Recommended Posts

Hello friends,

 

It works on some hosting and not working on the other however both hosting has same php.ini settings

 

after several times of trying i found the error should be in some where insite $sql entery but i don't know where or why.

 

can you please check the file

 

<?php
if ($_POST[url]) $url = urldecode($_POST[url]); else $url = urldecode($_GET[url]);
if ($_GET['r'])	// It is a redirect
{
$compos = explode("/", $_GET['r']);
$id = $compos[0];
$id = D1_base36_decode($id);

$sql = "SELECT `url`, `name`, `des`, `pub` FROM $table_urls WHERE `id` = $id LIMIT 0, 1";
$results = mysql_query($sql, $conn);

if ($rowfields = @mysql_fetch_array($results))
{

$sql = "UPDATE `$table_urls` SET `hits` = `hits`+1 WHERE `id` = $id";
mysql_query($sql, $conn);

$url = $rowfields[url];
$name = $rowfields[name];
$des = $rowfields[des];
$pub = $rowfields[pub];
$brmagacom = $rowfields[brmagacom];



$compocnt = count($compos);

for ($i=1; $i<$compocnt; $i++)
{
$url .= "\\" . $compos[$i];
}
$tpl = D1_processTemplate("redirect");
echo $tpl;
}
else
{
$tpl = D1_processTemplate("notfound");
echo $tpl;
}
}

elseif ($url)
{
$sql = "SELECT `url`, `name`, `des`, `pub` FROM $table_urls WHERE `id` = $id LIMIT 0, 1";
$results = mysql_query($sql, $conn);
if ($rowfields = @mysql_fetch_array($results)) // URL already present
{
$id = D1_base36_encode($rowfields[id]);
$tpl = D1_processTemplate("done");
echo $tpl;
}
else
{
$sql = "INSERT INTO $table_urls (url, name, des, pub, brmagacom) VALUES ('$url', '$name', '$des', '$pub', '$brmagacom')";
mysql_query($sql, $conn) or die(mysql_error());


$sql = "SELECT `id` FROM `$table_urls` WHERE `brmagacom` = '$brmagacom' LIMIT 0, 1";
$results = mysql_query($sql, $conn);

if ($rowfields = @mysql_fetch_array($results))
{
$id = D1_base36_encode($rowfields[id]);
$tpl = D1_processTemplate("done");
echo $tpl;
}
else
{
$tpl = D1_processTemplate("error");
echo $tpl;
}
}
}
else
{
$tpl = D1_processTemplate("welcome");
echo $tpl;
}


function D1_base36_encode($num)
{
if ($num<10)
return strval($num);
elseif ($num<36)
return chr(ord('a') + $num - 10);
else
return (D1_base36_encode((int)($num / 36)) . D1_base36_encode($num % 36));
}

// Function: D1_base36_decode()
function D1_base36_decode($str)
{
$str= strtolower($str);
$num = 0;
$len = strlen($str);
$pwr = $len - 1;
$pos = 0;
while ($pos < $len)
{
$digit = $str{$pos};
$ascdigit = ord(strval($digit));
$val = ($ascdigit >= ord("a")) ?
($ascdigit - ord("a") + 10) :
($ascdigit - ord("0"));
$num += $val * pow(36, $pwr);
$pos++;
$pwr--;
}
return $num;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/197528-something-is-wrong/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.