Hi! my name is Peter. iam working on the php platform.
while trying to run and compile a program i get the undefined offset error
iam nto much familiar with this error . Please help me . Thanks in advance.
Error: Undefined offset: 0 in /es/ePrintsStats/includes/inc.html.cumula tive_usage.es.p hp on line 16
The code: -
<?php
-
$current_year = date("Y");
-
$last_year = date("Y")-1;
-
-
?>
-
<p>Most viewed eprints:
-
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;range=4w">Past four weeks</a>]
-
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;year=<?php print $current_year; ?>">This year</a>]
-
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;year=<?php print $last_year; ?>">Last year</a>]
-
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date">All years</a>]
-
<br />Repository-wide statistics:
-
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=cumulative_usage;range=all">by Year/month</a>]
-
[<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=cumulative_usage_country">by Country</a>]
-
</p>
-
<?php
-
$max_count = $GLOBALS["db_values"][0]["abstracts"];
-
for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
-
{
-
if($max_count < $GLOBALS["db_values"][$rs]["abstracts"])
-
$max_count = $GLOBALS["db_values"][$rs]["abstracts"];
-
}
-
$max_width = '500'; // Max pixel width of barchart.
-
-
@
-
print '<font face="Arial" size="-1">Click on a month to see document downloads for that month.</font>';
-
print "<table>\n";
-
print '<tr><th bgcolor="#cccccc">Periods</th>
-
<th bgcolor="#66ddee">Abstracts</th>
-
<th bgcolor="#4477dd"><font color="#ffffff">Downloads</th>
-
<th bgcolor="#cccccc"> </th></tr>';
-
for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++)
-
{
-
$monthnum = (int) strpos('JanFebMarAprMayJunJulAugSepOctNovDec', $GLOBALS["db_values"][$rs]["month"])/3 + 1;
-
print '<tr><td><font face="Arial" size="-1"><a href="'.
-
$_SERVER['PHP_SELF'].
-
'?action=show_detail_date;year='.
-
$GLOBALS["db_values"][$rs]["year"].
-
';month=' .
-
$monthnum .
-
'">' .
-
$GLOBALS["db_values"][$rs]["year"].
-
' '.
-
$GLOBALS["db_values"][$rs]["month"].
-
'</a></font></td><td align="right"><font face="Arial" size="-1">'.
-
$GLOBALS["db_values"][$rs]["abstracts"].
-
'</font></td><td align="right"><font face="Arial" size="-1">'.
-
$GLOBALS["db_values"][$rs]["downloads"].
-
'</font></td>';
-
$cur_count = $GLOBALS["db_values"][$rs]["abstracts"];
-
$col_width = (int) ($cur_count/$max_count * $max_width);
-
$col_width = max($col_width, 1);
-
$col_width .= "px";
-
print '<td align="left"><img src="bars/hh.png" alt="abstracts" height="9" width="'.
-
$col_width .
-
'"><br />';
-
$cur_count = $GLOBALS["db_values"][$rs]["downloads"];
-
$col_width = (int) ($cur_count/$max_count * $max_width);
-
$col_width = max($col_width, 1);
-
$col_width .= "px";
-
print '<img src="bars/hp.png" alt="downloads" height="9" width="'.
-
$col_width .
-
'"></td></tr>';
-
}
-
print "</table>\n";
-
?>
-
6 4480 Please read the Posting Guidelines before you post in this forum! Especially the part about enclosing code within code or php tags!
And what is line 16?
Ronald :cool:
Please read the Posting Guidelines before you post in this forum! Especially the part about enclosing code within code or php tags!
And what is line 16?
Ronald :cool:
Thanks for the Reply,
line 16 is $max_count = $GLOBALS["db_values"][0]["abstracts"];
Undefined offset: 0 is the error that i come accross in the above line (line 16).
Okay .. think I'm just staring at this too long .. I have a random banner script that works just fine .. except one line is generating Undefined offset: 1 errors ...
The full script is .. -
<?php
-
-
-
$banner_File = "754.txt" ;
-
$total_Bannersize = 8 ;
-
-
-
-
$rnd_Value = Get754(0, $total_Bannersize-1);
-
$banner_Data = Get754Info($banner_File, $rnd_Value) ;
-
-
$Banner = split("::",$banner_Data);
-
-
$banner_Content = <<<content
-
-
<!-- Banner Ads Start -->
-
<a title="$Banner[2]" href="$Banner[1]" target="_blank"> <img name="Banner" src="$Banner[0]" alt = "$Banner[2]" border=0>
-
</a>
-
<!-- Banner Ads Ends -->
-
-
content;
-
-
echo $banner_Content ;
-
-
-
function Get754Info($filename, $line_number) {
-
-
$fp = @fopen($filename, "r")
-
or die ("Can't open file $filename on Line: " . __LINE__ . " in File: " . __FILE__);
-
-
$lnCounter = 0 ;
-
-
while (!feof ($fp)) {
-
$data = fgets($fp, 1024);
-
-
If ($lnCounter == $line_number){
-
$right_data = $data ;
-
return $right_data ;
-
break;
-
}
-
-
$lnCounter++ ;
-
}
-
}
-
-
-
function Get754($min, $max){
-
$mtime = ((double)microtime()* 100000) ;
-
$mtime = explode(" ", $mtime);
-
$mtime = floatval($mtime[1]) + floatval($mtime[0]) ;
-
$randval = mt_rand($min, $max);
-
return ($randval) ;
-
}
-
-
?>
-
The line returning the error is Line 50 .. - $mtime = floatval($mtime[1]) + floatval($mtime[0]) ;
What am I not seeing?
Oh .. PHP 5.0.4 ...
Thanks.
-bolo
Atli 5,058
Recognized Expert Expert
Hi, bolo, and welcome to TSDN!
You are trying to split a double value by using a space character. A double value has no space characters so it will not be split, but the entire value ends up in array index 0. -
function Get754($min, $max){
-
// This line will return something like 12345.54321
-
$mtime = ((double)microtime()* 100000) ;
-
-
// And this line tries to split on " " char, which doesn't exist
-
$mtime = explode(" ", $mtime);
-
-
// So $mtime[1] doesnt exist, ergo PHP returns a warning.
-
$mtime = floatval($mtime[1]) + floatval($mtime[0]) ;
-
-
// These two lines apear to be the only relevent lines.
-
// The other lines are redundant, from what I can tell.
-
$randval = mt_rand($min, $max);
-
return ($randval) ;
-
}
-
Hi Atli ..
YOU are a freakin' genius. Took the lines out. Everything still works. No error.
Thanks.
-bolo
Atli 5,058
Recognized Expert Expert
Hi Atli ..
YOU are a freakin' genius. Took the lines out. Everything still works. No error.
Thanks.
-bolo
Glad I could help :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I just switched error_reporting to ALL so I could debug my site. I got
a huge page full of errors. One of the most common was that in my
arrays I'm using undefined offsets and indexes. These still work fine,
but with error reporting at all they are marked as errors. Why? What
am I doing wrong?
www.monkeyclaus.org
|
by: Steven |
last post by:
Hi All,
I am moving some php code from a Linux machine to a Windows 2000 machine
with the code belowe I get the following error :
Notice: Undefined offset: 1 in c:\inetpub\wwwroot\test.php on line 5
1) reset($kolom1);
2) while(list($cat,$lnk) = each($kolom1)){
3) kop($cat);
|
by: google |
last post by:
Hello,
I'm having major problems trying to get my head round this problem.
I'm trying to generate an error free script, however, I still cannot
sort out this loop.
I get a "Notice: Undefined offset: 24 in
c:\inetpub\wwwroot\classes\file.php on line 348"
|
by: Richard Lawrence |
last post by:
Hi there,
I'm having a problem with PHP which I'm not sure how to best solve.
Here is the code:
$fp = fopen("comments.txt", "r");
while(!feof($fp))
{
$line = fgets($fp, 1024);
list($key, $value) = explode(":", $line, 2);
|
by: pareshgoel |
last post by:
class B
{
virtual ~B();
}
class D:public B
{
virtual ~D();
}
| |
by: vfunc |
last post by:
I get compile error:
undefined reference to snd_pcm_format_width.
I included the library directory with -I flag on gcc.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
|
by: delusion7 |
last post by:
I am getting this error "Undefined offset: 9 in C:\Course Technology\1687-5\Chapter.10\UpdateContactInfo.php on line 36"
this is the code I am recieving the error on:
if (mysqli_num_rows($QueryResult) > 0) {
$Row = mysqli_fetch_row($QueryResult);
$First = stripslashes($Row);
$Last = stripslashes($Row);
$Phone = stripslashes($Row);
$Address = stripslashes($Row);
$City = stripslashes($Row);
$State = stripslashes($Row);
|
by: simple12 |
last post by:
Hello
I have a script which have the facility of entering any code to some part of a webpage. I have some problems with it. When i put some code in the script then their is no error shown. When i try to not use a code and leave it empty the following php errors happens. I dont understand why. Help me.
Error shown are: -
PHP Notice: in file /index.php on line 132: Undefined offset: 4
PHP Notice: in file /index.php on line 141:...
|
by: neridaj |
last post by:
Hello,
I'm trying to figure out how to get rid of these errors:
Notice: Undefined offset: 1 in output_fns.php on line 315
Notice: getimagesize() : Read error! in
output_fns.php on line 315
function get_imgdim()
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |