You are here: GD library « PHP Programming Language « IT news, forums, messages
GD library

Posted by nathan.fulton on 10/26/06 19:29

Hey all,

I'm having issues with a script. When loaded, it should grab data from
a database, add 1 to the visits counter and then display the count in
the form of an image. The problem is this: when the script loads,
instead of adding 1 count to the database, it ads anywhere from 2 to 4
counts to the database. I was wondring is anyone knows whats going on
or how to fix it. I have attached my code below.

Thanks!

-Nathan

<?php
[database connection here]

$url = $_GET["url"];

//get the # of hits
$q = mysql($dbname, "SELECT * FROM counter WHERE url = '$url'");
$num = mysql_num_rows($q);
if($num != "0")
{
$do = mysql_fetch_object($q);
$newcount = $do->count + 1;
mysql($dbname, "UPDATE counter SET count = '$newcount' WHERE url =
'$url'");
mysql($dbname, "INSERT INTO counter_ip VALUES(0,'$url','$ip')");

$fontsize = "5";
}
else
{
$newcount = "user not found";
//establish font size
$fontsize = "3";
}
// create a 100*30 image
$im = imagecreate(100, 30);

// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// write the string at the top left
imagestring($im, $fontsize, 0, 0, $newcount, $textcolor);

// output the image
header("Content-type: image/png");
imagepng($im);
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация