Brain Fried, need some help please!

I have been working on this matter for about a week now and driving myself so nuts that now I can not even think right.

Here’s the problem.

I have a banner script which is used to display banners on my pages. It pulls from MySQL database and works fine.

The part that works fine is this:

if ($adtype == 1) {
echo "<a href="$site_url/banner.php?id=".$id."&amp;action=show" target="$target_text" onFocus="this.blur()"><img border="$border" style="border-color: $border_color" src="$site_url/$image" title="$alt" alt="$alt"></a>";
}

This part displays local banners and counts the views and clicks just fine.

This part displays the HTML snips like affiliate codes and such which are complete tags from elsewhere.

else {
echo $adtext;
}

The ads display just fine. Counts views for both types of ads using the SHOW fucntion.

if ($action == "show") {
$query = "SELECT * FROM $banners WHERE id = $id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$link = $row['link'];
if (strtolower(substr($link,0,5)) != "http:")
$link = "http://" . $link;
$today = date("d m Y");
$query = "SELECT * FROM $stats WHERE date_format(banner_date, '%d %m %Y') = '$today' AND id = $id";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
$today = date("Y-m-d"); 
$query = "UPDATE $stats SET clicks = clicks + 1 WHERE id = $id AND banner_date = '$today'";
$result = mysql_query($query) or die(mysql_error());
header("Location: ".$link);
}

What I need is to count the CLICKS for the HTML snip codes.

The $adtext; displays the ads fine pulling from the database but will NOT count the clicks. I know it is
because I can not call the SHOW function to increase the clicks like I do with local banners.

While going crazy I tried this to insure I am in the right place.

echo "<a href="$site_url/banner.php?id=".$id."&amp;action=show" target="$target_text" onFocus="this.blur()">1";
echo $adtext;
echo "</a>";

Which is NOT correct I know… BUT if I click on the number 1 displayed with this code it increments the clicks by one.
Mainly because I am calling the SHOW function.

I need a way to either call the SHOW function for the ads that are pulled and displayed using $adtext
or another function that can be used to do the same thing to count clicks.

Any help on this matter would be greatly appreciated! I also hope I am making sense here… Like I said, my brain is gone!

Let me just see if I’m getting you straight:

  • You have a page that displays the banner, as a link to banner.php.
  • You have a second page (banner.php) which is counting your clicks.

I’m not sure if you wanted to count the number of times the banner has been shown, but I’ll exclude it, because I’m assuming that your problem only occurs during a click.

What you want is banner.php to register a click, before redirecting the visitor to the external website, right?
Are you getting any errors (using error_reporting(E_ALL) and other debugging tricks)? Do the MySQL tables exist, or the columns that you’re trying to update? Are you creating new columns for new days?

First I would like to thank you for responding. I didn’t receive any notice of a response and was getting quite dis-heartened by that.

Anyway, I will try to narrow my need for help.

The problem:

I pull ad snippets from my database using this echo tag.

echo $adtext

This displays the ads fine and it counts the number of times this snippet has been viewed.

What it will NOT do is count the number of clicks on each snippet.

The main reason is this.

echo $adtext 

Doesn’t call any function or action to increment the count clicks.

This is what I need help with. How can I get, make or do a call to the action/function countClick when the echo tag is

echo $adtext 

My local banners call the SHOW function using the following.

if ($adtype == 1) {  
echo "<a href="$site_url/banner.php?id=".$id."&amp;action=show" target="$target_text" onFocus="this.blur()"><img border="$border" style="border-color: $border_color" src="$site_url/$image" title="$alt" alt="$alt"></a>";  
}

If it is NOT a local banner, adtype == 1, it uses ELSE to display the ADTEXT. Therefore never calling or triggering the countClick action as I can not figure out how to trigger it from

echo $adtext;

Does this make more sense?

Everything else works perfect and if I call the link directly in a browser it increments. I call it like this

http://www.domain.com/banners/banner.php?id=103&action=showURL

What I can not figure out is how to do the same thing in the PHP from echo $adtext;

No errors as nothing is being called/hit or triggered.

YES, it’s only a clicks issue or in this case, the lack there of!

Everything is their and works if I can just figure out how to call the action/function from the ADTEXT

echo $adtext;

Does nothing but output the value of $adtext. It doesn’t register clicks, doesn’t update or extract information from the database, etc.
You say you have a lauchpage banner.php, which you use to (randomly) show a banner and, if people click on it, should count that click. That means you just need to call your countClicks() function from that page, before redirecting the visitor to the target of the banner.

Any ideas or examples as to how I would accomplish this?

Everything I have tried doesn’t do anything except count more clicks each time a banner is displayed.

I see. It seems that your click-counting function is triggered by displaying a banner, rather than clicking it. Find where it’s triggered and change that to a view-counting function, then use the click-counting function in the launch-page.

Sponsor our Newsletter | Privacy Policy | Terms of Service