Um Posted February 1, 2007 Share Posted February 1, 2007 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! Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 there is something wrong with your query, $get_yesterday from the look and sound of it. Quote Link to comment Share on other sites More sharing options...
zq29 Posted February 1, 2007 Share Posted February 1, 2007 Sounds like your $get_yesterday query returned zero rows - Check that data exists in the database for the rows you are asking it to return. Quote Link to comment Share on other sites More sharing options...
Um Posted February 1, 2007 Author Share Posted February 1, 2007 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? Quote Link to comment Share on other sites More sharing options...
Orio Posted February 1, 2007 Share Posted February 1, 2007 What query are you running? Can you show a few lines of code? Orio. Quote Link to comment Share on other sites More sharing options...
Um Posted February 1, 2007 Author Share Posted February 1, 2007 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"); Quote Link to comment Share on other sites More sharing options...
Orio Posted February 1, 2007 Share Posted February 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
Um Posted February 1, 2007 Author Share Posted February 1, 2007 No, still same error. I am so down. Now I don't even have any will to continue. I do not know what to do... Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 2, 2007 Share Posted February 2, 2007 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()); Quote Link to comment Share on other sites More sharing options...
Um Posted February 2, 2007 Author Share Posted February 2, 2007 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... Quote Link to comment Share on other sites More sharing options...
Um Posted February 2, 2007 Author Share Posted February 2, 2007 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? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 2, 2007 Share Posted February 2, 2007 that code for the query should produce the error in your sql syntax. Quote Link to comment Share on other sites More sharing options...
Um Posted February 2, 2007 Author Share Posted February 2, 2007 whell, I have fix previous error thanks to you, but I can't see numbers. What should I do? here you can see my test page: www.piranhastudio.com/proba.php Quote Link to comment Share on other sites More sharing options...
Um Posted February 2, 2007 Author Share Posted February 2, 2007 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! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 2, 2007 Share Posted February 2, 2007 Check the stickied topic about header errors. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 2, 2007 Share Posted February 2, 2007 i can see numbers. i get some header errors which you should fix by using output buffering. this is what i see: Online: 2 Today: 3 Yesterday: 4 This month: 21 This year: 22 Total page views: 22 Last visit: / Quote Link to comment Share on other sites More sharing options...
Um Posted February 2, 2007 Author Share Posted February 2, 2007 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! Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 2, 2007 Share Posted February 2, 2007 No problems Um, not sure how it fixed your problem though. Could you please mark the topic as solved, for the others. thanks. Quote Link to comment Share on other sites More sharing options...
Um Posted February 2, 2007 Author Share Posted February 2, 2007 I don't know, too. Altought, I don't know anything, so why should i know this? ;D I'll be back, don't worry... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.