Page 1 of 1

Problem with passed url

Posted: Sun May 25, 2008 10:40 am
by csdavis0906
I have the lines of code below calling hitCounter.php and passing it 2 parameters, tag and url. hitCounter.php has 2 purposes: first, to open the url of a external page and secondly to update the table (which works fine).

Opening the url's works some of the time and at others I get "the requested URL \$page\ was not found" when, in fact, the proper url's are being passed. Anyway, below is the calling line of code and then the program called:

Code: Select all

 
// calling line
$destination = urlencode($url);
echo '<td class="title"><a href="hitCounter.php?tag='.$tag.'&url=' . $destination . '">'. $title .'</a></td><td></td>';

Code: Select all

 
// hitCounter.php
<?php
// get url passed
$page = $_SERVER['QUERY_STRING'];
$page = urldecode($_GET['url']);
 
// open url passed
ob_start();
$uri = 'http://';
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/$page/');
 
// get tag passed from url
$search = $_SERVER['QUERY_STRING'];
$search = strtolower($_GET['tag']);
 
require_once('mysql_connect.php');
// update  hit count
$result = mysql_query("UPDATE words SET count=count+1 WHERE root='$tag'");
?>
 
Anyone have any ideas what I'm doing wrong? Thanking you in advance for any help you can provide.

Re: Problem with passed url

Posted: Sun May 25, 2008 11:09 am
by califdon
csdavis0906 wrote:

Code: Select all

 
// calling line
$destination = urlencode($url);
echo '<td class="title"><a href="hitCounter.php?tag='.$tag.'&url=' . $destination . '">'. $title .'</a></td><td></td>';

Code: Select all

 
// hitCounter.php
<?php
// get url passed
[color=#FF0000]$page = $_SERVER['QUERY_STRING'];[/color]
[color=#FF0000]$page = urldecode($_GET['url']);[/color]
 
// open url passed
ob_start();
$uri = 'http://';
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/$page/');
 
// get tag passed from url
[color=#FF0000]$search = $_SERVER['QUERY_STRING'];[/color]
[color=#FF0000]$search = strtolower($_GET['tag']);[/color]
 
require_once('mysql_connect.php');
// update  hit count
$result = mysql_query("UPDATE words SET count=count+1 WHERE root='$tag'");
?>
 
Anyone have any ideas what I'm doing wrong? Thanking you in advance for any help you can provide.
I don't quite understand what you are doing, but I notice that you are reassigning different values successively to the same variable, and assigning the same value to different variables. I cannot follow your logic.

Re: Problem with passed url

Posted: Sun May 25, 2008 11:26 am
by csdavis0906
I have a list of articles gathered from rss feeds. The articles are listed by title and summary. When a user clicks on any title he will be redirected to the actual news source.

Each time a user clicks on a title I am updating a hit counter so that eventually the program will show each subject's (tag) popularity with a treemap. Visit http://world.newsalizr.com to see how it works. Thanks for your interest.