Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Nate

Nate Avatar

**
Official Member

85


July 2007
Alright here is the code I am using:

<?php
include "db.php";

if (isset($id)){
$update = mysql_query("UPDATE affiliates SET views = views + 1 WHERE id='$id'");
$result = mysql_query("SELECT link FROM affiliates WHERE id='$id'");
$row = mysql_fetch_array($result);
$afflink = $row['link'];
header("Location: $afflink");
mysql_close();}
?>

And the redirection isn't working can anyone help?


Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Try this.

<?php
include "db.php";

if (isset($id)){
$update = mysql_query("UPDATE affiliates SET views = views + 1 WHERE id='$id'");
$result = mysql_query("SELECT link FROM affiliates WHERE id='$id'");
$row = mysql_fetch_array($result);
$afflink = $row['link'];
header("Location: ".$afflink);
mysql_close();
exit();
}
?>

Nate

Nate Avatar

**
Official Member

85


July 2007
That doesn't work either.

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
I never was good with header(); :P

Wait for Yami.. he should know. =/

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
yeah... header can be a pain in the ass.. lol... i'll help in a sec... just back from work.. kinda knackered lol

btw
HTTP/1.1 requires an absolute URI as argument to Location:
including the scheme, hostname and absolute path, but some clients
accept relative URIs. You can usually use $_SERVER['HTTP_HOST'],
$_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a
relative one yourself



i have a simalar script (if its what i think you are doing)

just using arrays for affiliate links.. if its what i think your doing then i can edit it to work with sql not arrays...

i'll post it in a while

EDIT:


<?
include('db.php');

if (isset($id)){
   $sql = "UPDATE `affiliates` SET `views` = `views` + 1 WHERE `id`='$id'";
   $sql = mysql_query($sql) or die(mysql_error());
}

while  ($r=mysql_fetch_array($sql)) {
   $sqlr = "SELECT `link` FROM `affiliates` WHERE `id` = '$id'";
   $sqlr = mysql_query($sqlr) or die(mysql_error());
   $afflink = $r['link'];
   header(Location: $afflink);
   mysql_close();
}
exit();
?>


as i say i've just got back from work so that probally won't work lol


Last Edit: Nov 26, 2005 14:39:53 GMT by Llanilek

Nate

Nate Avatar

**
Official Member

85


July 2007
Doesn't work :P

newBookmarkLockedFalling