> function updateHitCounter($id,$PHPSESSID,$type){
> $flag=$this->validateSession($PHPSESSID);
> if($flag==1){
> include("admin/config.inc.php");
> $connection = mysql_connect("$host","$username","$password");
> if ($connection == false){
> echo mysql_errno().": ".mysql_error()."<BR>";
> exit;
> }
> if($type=="out") $query = "select * from sites where id='$id'";
> elseif($type=="in") $query = "select * from sites where id='$id'";
# It's the same query?...
> $result = mysql_db_query ("$dbase", $query);
> if ($result){
> $numOfRows = mysql_num_rows ($result);
> $hitsIn= mysql_result ($result, $i, "hitsOut");
> $hitsOut= mysql_result ($result, $i, "hitsIn");
I'm guessing one of these is line 222, and you have no record for that '$id'
yet in your database.
For a brand new site, you'll need to register them first, or stick an @ in
front of these, or...
Or, just use your $numOfRows to decide if there's a value to retrieve or
not.
> }else{
> echo mysql_errno().": ".mysql_error()."<BR>";
> }
> if($type=="out"){
> $hits=$hitsOut;
> }else{
> $hits=$hitsIn;
> }
> $hits++;
> $query = "UPDATE sites SET hitsOut ='$hits' WHERE id='$id'";
And this has no effect, since there are no rows with that id of '$id'
> $result = mysql_db_query ("$dbase", $query);
> if (!$result){
> echo mysql_errno().": ".mysql_error()."<BR>";
> }
> mysql_close ();
> }
> }
> When I run it i get this error:
> Warning: Unable to jump to row 0 on MySQL result index 4 in c:\program
> files\apache group\apache\htdocs\phptopsites\top100.php on line 222
> Guys is there anyway i can avoid it?
Unless there's more to this function you are not showing, you could just do:
function updateHitCounter($id,$PHPSESSID,$type){
$flag=$this->validateSession($PHPSESSID);
if($flag==1){
include("admin/config.inc.php");
$connection = mysql_connect("$host","$username","$password");
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
$query = "update sites set $type = $type + 1 where id = '$id'";
$update = mysql_query($query);
}
}
You could then use http://php.net/mysql_affected_rows to find out if there
was a site you even updated...
--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]