manalnor Posted April 4, 2010 Share Posted April 4, 2010 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; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/197528-something-is-wrong/ Share on other sites More sharing options...
greatstar00 Posted April 4, 2010 Share Posted April 4, 2010 what is not working, can u be specific? Quote Link to comment https://forums.phpfreaks.com/topic/197528-something-is-wrong/#findComment-1036687 Share on other sites More sharing options...
TeddyKiller Posted April 4, 2010 Share Posted April 4, 2010 Which $sql is it too. You have quite a few. Hence why sometimes it might be best to change the names of them. $sql1, $sql2, or if you just pasted the actual query to us that has the problem. Quote Link to comment https://forums.phpfreaks.com/topic/197528-something-is-wrong/#findComment-1036720 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.