Jump to content

[SOLVED] (for me) uknown error


Um

Recommended Posts

Hello to all.

 

I am new here and I already have help-question for you.

 

I have download one web stats to show mw how many visitors is online at the moment, how many was on my site yesterday, this month, this year...etc...

 

I have read and I did everything by howto.txt file.

 

But now I have this error on my site:

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 10 in /home/www/web2192/html/wwwstats/stats.php on line 306

 

In line 306 is this:

 

$get_yesterday_number = mysql_result($get_yesterday, 0, "number");

 

Can you help me please?

 

Thanx in advance!  ;)

Link to comment
Share on other sites

I have look inside my DB and I have seen table for today online, for this month, for this year, etc... but I didn't see any table for Yesterday.

Maybe it doesn need table for yesterday?

 

Maybe yesterday is not needed because it gets data from today table or?

 

 

Link to comment
Share on other sites

Query? I would like to answer, but I am new in PHP and I still doesnt know some things. Here are some of my codes:

 

//update if there is more online viewers
if($get_mnow_number < $now_number){
mysql_query("UPDATE stats SET day = $day_d,
			month = $month_d,
			year = $year_d,
			hour = $hour_d,
			minute = $minute_d,
			number = $now_number WHERE main = 'mnow';");
}
//get stats
$get_stats = mysql_query("SELECT * FROM stats;");
//since
$get_since_day = mysql_result($get_stats, 1, "day");
$get_since_month = mysql_result($get_stats, 1, "month");
$get_since_year = mysql_result($get_stats, 1, "year");
//if no since write date
if($get_since_day == "0" && $get_since_month == "0" && $get_since_year == "0"){
mysql_query("UPDATE stats SET day = $day_d,
			month = $month_d,
			year = $year_d,
			hour = $hour_d,
			minute = $minute_d WHERE main = 'since';");
}
//all
$all_number = mysql_result($get_stats, 0, "number");//get all number
$all_number++;//all number +1
mysql_query("UPDATE stats SET number = $all_number WHERE main = 'all';");//update
//today
$get_day = mysql_query("SELECT * FROM stats_day ORDER BY id DESC;");//get day
$get_day_rows = mysql_num_rows($get_day);//get day rows
$get_day_id = mysql_result($get_day, 0, "id");
$get_day_day = mysql_result($get_day, 0, "day");
if($get_day_rows == "0"){
mysql_query("INSERT INTO stats_day (year,month,day,number) VALUES ($year_d,$month_d,$day_d,'1');");//insert if rows = 0
} else {
if($get_day_day != $day_d){
	mysql_query("INSERT INTO stats_day (year,month,day,number) VALUES ($year_d,$month_d,$day_d,'1');");//insert new if day is not equal to todays date
} else {
	mysql_query("UPDATE stats_day SET number = number+1 WHERE id = $get_day_id;");//update number if day is todays date
}
}
$get_day_p = mysql_query("SELECT * FROM stats_day ORDER BY id DESC;");//get today number
$day_number_p = mysql_result($get_day_p, 0, "number");
//yesterday
$day_dy = $day_d;
$day_my = $month_d;
$day_yy = $year_d;
$day_dy--;
if($day_dy <= "0"){
$day_my--;
if($day_my <= "0"){
	$day_yy--;
	$day_my = "12";
}
$day_dy = $month_days[$day_my];
}
$get_yesterday = mysql_query("SELECT * FROM stats_day WHERE day = $day_dy AND month = $day_my AND year = $day_yy;");
$get_yesterday_number = mysql_result($get_yesterday, 0, "number");
if(!$get_yesterday_number){
$yesterday_number = "0";
} else {
$yesterday_number = $get_yesterday_number;
}
//this month
$get_month = mysql_query("SELECT * FROM stats_month ORDER BY id DESC;");
$get_month_rows = mysql_num_rows($get_month);
$get_month_id = mysql_result($get_month, 0, "id");
$get_month_month = mysql_result($get_month, 0, "month");
if($get_month_rows == "0"){
mysql_query("INSERT INTO stats_month (year,month,number) VALUES ($year_d,$month_d,'1');");
} else {
if($get_month_month != $month_d){
	mysql_query("INSERT INTO stats_month (year,month,number) VALUES ($year_d,$month_d,'1');");
} else {
	mysql_query("UPDATE stats_month SET number = number+1 WHERE id = $get_month_id;");
}
}
$get_month_p = mysql_query("SELECT * FROM stats_month ORDER BY id DESC;");
$month_number_p = mysql_result($get_month_p, 0, "number");
//this year
$get_year = mysql_query("SELECT * FROM stats_year ORDER BY id DESC;");
$get_year_rows = mysql_num_rows($get_year);
$get_year_id = mysql_result($get_year, 0, "id");
$get_year_year = mysql_result($get_year, 0, "year");
if($get_year_rows == "0"){
mysql_query("INSERT INTO stats_year (year,number) VALUES ($year_d,'1');");
} else {
if($get_year_year != $year_d){
	mysql_query("INSERT INTO stats_year (year,number) VALUES ($year_d,'1');");
} else {
	mysql_query("UPDATE stats_year SET number = number+1 WHERE id = $get_year_id;");
}
}
$get_year_p = mysql_query("SELECT * FROM stats_year ORDER BY id DESC;");
$year_number_p = mysql_result($get_year_p, 0, "number");

Link to comment
Share on other sites

Try changing this:

$get_yesterday = mysql_query("SELECT * FROM stats_day WHERE day = $day_dy AND month = $day_my AND year = $day_yy;");

 

Into this:

$get_yesterday = mysql_query("SELECT * FROM stats_day WHERE day='$day_dy' AND month='$day_my' AND year='$day_yy'");

 

 

Orio.

Link to comment
Share on other sites

OK guys, I will try later. Hope this will do the trick. In advance I can say that you are the best!

 

So quick and so many answers you can get anywhere!

 

I will always advertise your forum!

 

See ya later, I will be here and tell you my result, if I have fix it or not...

Link to comment
Share on other sites

alright add change that same line to this:

$get_yesterday = mysql_query("SELECT * FROM stats_day WHERE day='$day_dy' AND month='$day_my' AND year='$day_yy'") or die("Error in mysql: ".mysql_error());

 

IT WORKS THANKS!!

 

I mean there is no error anymore, but also, there is no numbers, too (there is text, but no number how many visiotor is online at the moment).

 

I have insert everything what is needed, what I have read in read me file (text from read me file):

 

1.) Copy wwwstats folder to server

2.) Run /wwwstats/install and follow the instructions (cfg.php must be chmoded to 0666)

3.) Import ip2country.sql or ip2country.csv to table ip2country (created by setup)

4.) Delete install folder in wwwstats directory

5.) include cookie.php and stats.php into index file of yours website

 

  <?php

    include("wwwstats/cookie.php");

  ?>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

  <link rel="stylesheet" type="text/css" href="style.css" />

    ...

    ...

  <body>

    ...

    ...

  <?php

    include("wwwstats/stats.php");

  ?>

    ...

    ...

  </body>

 

WARNING!:

cookie.php must be included before any html tag!

 

---- live stats usage ----

 

Use something like this for live stats:

 

  <?php

    echo "<b>Online:</b> ".$now_number . "<br />";

    echo "<b>Today:</b> ".$day_number_p . "<br />";

    echo "<b>Yesterday:</b> ".$yesterday_number . "<br />";

    echo "<b>This month:</b> ".$month_number_p . "<br />";

    echo "<b>This year:</b> ".$year_number_p . "<br />";

    echo "<b>Total page views:</b> ".$all_number . "<br />";

    echo "<b>Last visit:</b> ".$clast . "<br />";

  ?>

 

and this is code from my "test" page:

 

  <?php
    include("http://www.piranhastudio.com/wwwstats/cookie.php");
  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
    include("http://www.piranhastudio.com/wwwstats/stats.php");
    echo "<b>Online:</b> ".$now_number . "<br />";
    echo "<b>Today:</b> ".$day_number_p . "<br />";
    echo "<b>Yesterday:</b> ".$yesterday_number . "<br />";
    echo "<b>This month:</b> ".$month_number_p . "<br />";
    echo "<b>This year:</b> ".$year_number_p . "<br />";
    echo "<b>Total page views:</b> ".$all_number . "<br />";
    echo "<b>Last visit:</b> ".$clast . "<br />";
  ?>
</body>
</html>

 

Any ideas?

 

 

Link to comment
Share on other sites

I have delete this:

 

    include("http://www.piranhastudio.com/wwwstats/stats.php");

 

to this

 

    include("wwwstats/stats.php");

 

ANd now works.

 

but I have get new error, this:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/www/web2192/html/proba.php:1) in /home/www/web2192/html/wwwstats/cookie.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at /home/www/web2192/html/proba.php:1) in /home/www/web2192/html/wwwstats/cookie.php on line 5

 

This is not possible!

Link to comment
Share on other sites

GUYS AND GIRLS:

 

IT IS OVER! DONE!

 

EVERYTHING  W O R K S !!!

 

THANKS TO YOU ALL MILION TIMES!!! MORE THAN MILION!

 

Something was wrong with this test page, but when I insert this same modifications to my real site, everything works just fine!

 

How can I ever thank you for your help?

 

Thank you again! You are the best!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.