473,396 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Undefined Index notices

I'm getting this:

[client 192.168.5.50] PHP Notice: Undefined index: D1 in
/var/www/html.....

From this line of code:

$id_option = $_POST['D1'];

Which is posted by this:

<form target="_blank" method="POST" action="mailchart.php" name="mail_data">
<input type="hidden" name="D1" value="<? echo $id_option; ?>">
<input type="submit" value="View Chart"></p>
</form>

My question is why?

I *am* getting the correct value for $_POST['D1'] and at this point in
time am really quite confused because that notice is getting thrown.

[root@... ~]# php -v
PHP 4.3.11 (cgi) (built: Nov 8 2005 06:24:40)

[root@... /]# uname -a
Linux ... 2.6.12-2.3.legacy_FC3 #1 Sun Feb 19 10:47:10 EST 2006 i686
i686 i386 GNU/Linux

Thanks..

Craig
Jun 8 '06 #1
26 3710
Craig Morrison schrieb:
I'm getting this:

[client 192.168.5.50] PHP Notice: Undefined index: D1 in
/var/www/html.....

From this line of code:

$id_option = $_POST['D1'];

Which is posted by this:

<form target="_blank" method="POST" action="mailchart.php"
name="mail_data">
<input type="hidden" name="D1" value="<? echo $id_option; ?>">
<input type="submit" value="View Chart"></p>
</form>

My question is why?

I *am* getting the correct value for $_POST['D1'] and at this point in
time am really quite confused because that notice is getting thrown.


Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)? In
such cases I usually try this first; if $_POST['D1'] is set at the top
of the script you might find out where it gets lost.

--
Markus
Jun 9 '06 #2
Markus Ernst wrote:
Craig Morrison schrieb:
I'm getting this:

[client 192.168.5.50] PHP Notice: Undefined index: D1 in
/var/www/html.....

From this line of code:

$id_option = $_POST['D1'];

Which is posted by this:

<form target="_blank" method="POST" action="mailchart.php"
name="mail_data">
<input type="hidden" name="D1" value="<? echo $id_option; ?>">
<input type="submit" value="View Chart"></p>
</form>

My question is why?

I *am* getting the correct value for $_POST['D1'] and at this point in
time am really quite confused because that notice is getting thrown.


Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)? In
such cases I usually try this first; if $_POST['D1'] is set at the top
of the script you might find out where it gets lost.


The question is, if it's invalid how come I am getting the correct value
that is POSTed to the script?

Craig
Jun 9 '06 #3
Craig Morrison wrote:
Markus Ernst wrote:
Craig Morrison schrieb:
I'm getting this: [snip] My question is why?

I *am* getting the correct value for $_POST['D1'] and at this point in
time am really quite confused because that notice is getting thrown.


Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)? In
such cases I usually try this first; if $_POST['D1'] is set at the top
of the script you might find out where it gets lost.


The question is, if it's invalid how come I am getting the correct value
that is POSTed to the script?


That's a pretty moot question, unless you think magic is causing it.

Consider it a flaw/bug in your construction. Markus' suggestion might get
you some insight into what might be the problem.

/Bent
Jun 9 '06 #4
Bent Stigsen wrote:
Craig Morrison wrote:
Markus Ernst wrote:
Craig Morrison schrieb:
I'm getting this: [snip] My question is why?

I *am* getting the correct value for $_POST['D1'] and at this point in
time am really quite confused because that notice is getting thrown.
Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)? In
such cases I usually try this first; if $_POST['D1'] is set at the top
of the script you might find out where it gets lost.

The question is, if it's invalid how come I am getting the correct value
that is POSTed to the script?


That's a pretty moot question, unless you think magic is causing it.

Consider it a flaw/bug in your construction. Markus' suggestion might get
you some insight into what might be the problem.

/Bent


How is it moot?

A form posts the value for D1 to a script, script looks for the value of
D1 and gets it. PHP raises a notice that D1 is undefined.

I don't understand how I am getting the value that is posted to the
script if the index is undefined.

Is it really that difficult for someone to explain this?

Craig
Jun 9 '06 #5
Bent Stigsen wrote:
Craig Morrison wrote:
Markus Ernst wrote:
Craig Morrison schrieb:
I'm getting this: [snip] My question is why?

I *am* getting the correct value for $_POST['D1'] and at this point in
time am really quite confused because that notice is getting thrown.
Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)? In
such cases I usually try this first; if $_POST['D1'] is set at the top
of the script you might find out where it gets lost.

The question is, if it's invalid how come I am getting the correct value
that is POSTed to the script?


That's a pretty moot question, unless you think magic is causing it.

Consider it a flaw/bug in your construction. Markus' suggestion might get
you some insight into what might be the problem.

/Bent


As a follow up, print_r($_POST) yields:

Array
(
[D1] => 3
)

And I still get the notice..

Craig
Jun 9 '06 #6
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote:
Markus Ernst wrote:
Craig Morrison schrieb:
> I'm getting this: [snip]
> My question is why?
>
> I *am* getting the correct value for $_POST['D1'] and at this point in
> time am really quite confused because that notice is getting thrown.
Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)?
In such cases I usually try this first; if $_POST['D1'] is set at the
top of the script you might find out where it gets lost.
The question is, if it's invalid how come I am getting the correct value
that is POSTed to the script?


That's a pretty moot question, unless you think magic is causing it.

Consider it a flaw/bug in your construction. Markus' suggestion might get
you some insight into what might be the problem.

/Bent


How is it moot?


Well, I can't see how PHP would get the value, if the index was invalid or
non-existing.
A form posts the value for D1 to a script, script looks for the value of
D1 and gets it. PHP raises a notice that D1 is undefined.

I don't understand how I am getting the value that is posted to the
script if the index is undefined.

Is it really that difficult for someone to explain this?


Yes, because in all likelyhood, that is not what is happening.

Arrays and forms are so commonly used that, if it was a bug then it would be
reported all over the place.
/Bent
Jun 9 '06 #7
Bent Stigsen wrote:
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote:

Markus Ernst wrote:
> Craig Morrison schrieb:
>> I'm getting this:
[snip]
>> My question is why?
>>
>> I *am* getting the correct value for $_POST['D1'] and at this point in
>> time am really quite confused because that notice is getting thrown.
> Have you checked this, i.e. with print_r($_POST) or var_dump($_POST)?
> In such cases I usually try this first; if $_POST['D1'] is set at the
> top of the script you might find out where it gets lost.
The question is, if it's invalid how come I am getting the correct value
that is POSTed to the script?
That's a pretty moot question, unless you think magic is causing it.

Consider it a flaw/bug in your construction. Markus' suggestion might get
you some insight into what might be the problem.

/Bent

How is it moot?


Well, I can't see how PHP would get the value, if the index was invalid or
non-existing.
A form posts the value for D1 to a script, script looks for the value of
D1 and gets it. PHP raises a notice that D1 is undefined.

I don't understand how I am getting the value that is posted to the
script if the index is undefined.

Is it really that difficult for someone to explain this?


Yes, because in all likelyhood, that is not what is happening.

Arrays and forms are so commonly used that, if it was a bug then it would be
reported all over the place.
/Bent


I didn't say that it was a bug..

I'd yell louder if I thought it was. :-)

But I am getting the correct value, as you can see from the follow up
that I posted which does a print_r..

Craig
Jun 9 '06 #8
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote: [snip]
A form posts the value for D1 to a script, script looks for the value of
D1 and gets it. PHP raises a notice that D1 is undefined.

I don't understand how I am getting the value that is posted to the
script if the index is undefined.

Is it really that difficult for someone to explain this?
Yes, because in all likelyhood, that is not what is happening.

Arrays and forms are so commonly used that, if it was a bug then it would
be reported all over the place.
/Bent


I didn't say that it was a bug..

I'd yell louder if I thought it was. :-)


Sorry, if what you say is happening, really is happening, then it is a bug,
and since you didn't take Markus seriously, I assumed you did think it was.
But I am getting the correct value, as you can see from the follow up
that I posted which does a print_r..


You must be doing something or making assumptions that you consider
unimportant to tell, because it doesn't make sense. Are you sure you are
not seeing the notice *before* submitting the form, or subsequently do a
redirect, or do some fiddling with the _POST-array elsewhere?
/Bent
Jun 9 '06 #9
Bent Stigsen wrote:
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote: [snip] A form posts the value for D1 to a script, script looks for the value of
D1 and gets it. PHP raises a notice that D1 is undefined.

I don't understand how I am getting the value that is posted to the
script if the index is undefined.

Is it really that difficult for someone to explain this?
Yes, because in all likelyhood, that is not what is happening.

Arrays and forms are so commonly used that, if it was a bug then it would
be reported all over the place.
/Bent I didn't say that it was a bug..

I'd yell louder if I thought it was. :-)


Sorry, if what you say is happening, really is happening, then it is a bug,
and since you didn't take Markus seriously, I assumed you did think it was.


You shouldn't make assumptions, that is a fatal flaw. You assumed that I
didn't take his advice seriously. Don't jump to conclusions it makes you
look like a, well... That's another matter, read on..
But I am getting the correct value, as you can see from the follow up
that I posted which does a print_r..


You must be doing something or making assumptions that you consider
unimportant to tell, because it doesn't make sense. Are you sure you are
not seeing the notice *before* submitting the form, or subsequently do a
redirect, or do some fiddling with the _POST-array elsewhere?


I am not making any assumptions, just writing code according to the
documentation. I gave the HTML that posts its results already..

These are the first 3 lines of the script that gets posted to..

<?
include 'inc/config.inc.php';
?>

The notice is generated in config.inc.php, which follows...

<?
// define query titles
$id_text[1]="Group Total Sent &amp; Received";
$id_text[2]="EU Total Sent &amp; Received";
$id_text[3]="EU Total Sent";
$id_text[4]="EU Total Received";
$id_text[5]="EU Sent By User";
$id_text[6]="EU Received By User";
$id_text[7]="US Total Sent &amp; Received";
$id_text[8]="US Total Sent";
$id_text[9]="US Total Received";
$id_text[10]="US Sent By User";
$id_text[11]="US Received By User";
$id_text[12]="All Domains";

// define view names
$id_view[1]="GroupTotal";
$id_view[2]="EUTotal";
$id_view[3]="EUAllSent";
$id_view[4]="EUAllRcvd";
$id_view[5]="EUSent";
$id_view[6]="EURcvd";
$id_view[7]="USTotal";
$id_view[8]="USAllSent";
$id_view[9]="USAllRcvd";
$id_view[10]="USSent";
$id_view[11]="USRcvd";
$id_view[12]="AllDomainsTotal";

// define column styles
$fc_col_styles['TOTAL'] = 'no';
$fc_col_styles['Total'] = 'no';
$fc_col_styles['SENT'] = 'no';
$fc_col_styles['Sent'] = 'no';
$fc_col_styles['RCVD'] = 'no';
$fc_col_styles['Rcvd'] = 'no';
$fc_col_styles['Month'] = 'mo';
$fc_col_styles['MONTH'] = 'mo';
$fc_col_styles['User'] = 'us';
$fc_col_styles['USER'] = 'us';
$fc_col_styles['MBytes'] = 'mb';
$fc_col_styles['MBYTES'] = 'mb';

// set default values
$id_text_count = 12;
$id_option = 1;

// determine what view we are querying
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$id_option = $_POST['D1']; // <=== DING we have winner, notice gets raised
else if ($_SERVER['REQUEST_METHOD'] == 'GET')
$id_option = $_GET['D1'];

if (($id_option == 0) || ($id_option > $id_text_count)) {$id_option = 1;}
$selectID = $id_view[$id_option];
?>

As you can see, there is nothing but good php there.

Now, here's where I get pissed off. You all assumed that I was just
pissing in the wind. I gave a good explanation of what I was doing
before and this code tells you nothing more.

Next time, ask for answers before being an ass and assuming you are
working with a n00b..

Craig
Jun 9 '06 #10
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote: [snip]
> A form posts the value for D1 to a script, script looks for the value
> of D1 and gets it. PHP raises a notice that D1 is undefined.
>
> I don't understand how I am getting the value that is posted to the
> script if the index is undefined.
>
> Is it really that difficult for someone to explain this?
Yes, because in all likelyhood, that is not what is happening.

Arrays and forms are so commonly used that, if it was a bug then it
would be reported all over the place.
/Bent
I didn't say that it was a bug..

I'd yell louder if I thought it was. :-)


Sorry, if what you say is happening, really is happening, then it is a
bug, and since you didn't take Markus seriously, I assumed you did think
it was.


You shouldn't make assumptions, that is a fatal flaw. You assumed that I
didn't take his advice seriously. Don't jump to conclusions it makes you
look like a, well... That's another matter, read on..


Yes yes, I know I can be an insensitive prick. Honestly, I try to better
myself. Perhaps I grow up someday.
But I am getting the correct value, as you can see from the follow up
that I posted which does a print_r..


You must be doing something or making assumptions that you consider
unimportant to tell, because it doesn't make sense. Are you sure you are
not seeing the notice *before* submitting the form, or subsequently do a
redirect, or do some fiddling with the _POST-array elsewhere?


I am not making any assumptions, just writing code according to the
documentation. I gave the HTML that posts its results already..

These are the first 3 lines of the script that gets posted to..

<?
include 'inc/config.inc.php';
?>

The notice is generated in config.inc.php, which follows...

[snip] // determine what view we are querying
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$id_option = $_POST['D1']; // <=== DING we have winner, notice gets raised
else if ($_SERVER['REQUEST_METHOD'] == 'GET')
$id_option = $_GET['D1'];

if (($id_option == 0) || ($id_option > $id_text_count)) {$id_option = 1;}
$selectID = $id_view[$id_option];
?>

As you can see, there is nothing but good php there.
Yes, it looks fine.
Now, here's where I get pissed off. You all assumed that I was just
pissing in the wind. I gave a good explanation of what I was doing
before and this code tells you nothing more.

Next time, ask for answers before being an ass and assuming you are
working with a n00b..


Sorry I couldn't be more sensitive in my wording, but I think you are being
a bit touchy. For the record, I didn't think you were a n00b, just one of
those guys with an infinite faith in their own infallibility, who
apparently get all huffy at the mere suggestion that they made an error.

If you find it to be some funky bug in PHP, then I will unreservedly
apologize for anything you find fit. Alternatively when you find it to be
some banal mistake in your code, I hope you'll find it in you to forgive my
bruteness.
/Bent
Jun 9 '06 #11
Bent Stigsen wrote:
Craig Morrison wrote:
Bent Stigsen wrote:
Craig Morrison wrote:
Bent Stigsen wrote:
> Craig Morrison wrote:
[snip]
>> A form posts the value for D1 to a script, script looks for the value
>> of D1 and gets it. PHP raises a notice that D1 is undefined.
>>
>> I don't understand how I am getting the value that is posted to the
>> script if the index is undefined.
>>
>> Is it really that difficult for someone to explain this?
> Yes, because in all likelyhood, that is not what is happening.
>
> Arrays and forms are so commonly used that, if it was a bug then it
> would be reported all over the place.
>
>
> /Bent
I didn't say that it was a bug..

I'd yell louder if I thought it was. :-)
Sorry, if what you say is happening, really is happening, then it is a
bug, and since you didn't take Markus seriously, I assumed you did think
it was. You shouldn't make assumptions, that is a fatal flaw. You assumed that I
didn't take his advice seriously. Don't jump to conclusions it makes you
look like a, well... That's another matter, read on..


Yes yes, I know I can be an insensitive prick. Honestly, I try to better
myself. Perhaps I grow up someday.
But I am getting the correct value, as you can see from the follow up
that I posted which does a print_r..
You must be doing something or making assumptions that you consider
unimportant to tell, because it doesn't make sense. Are you sure you are
not seeing the notice *before* submitting the form, or subsequently do a
redirect, or do some fiddling with the _POST-array elsewhere?

I am not making any assumptions, just writing code according to the
documentation. I gave the HTML that posts its results already..

These are the first 3 lines of the script that gets posted to..

<?
include 'inc/config.inc.php';
?>

The notice is generated in config.inc.php, which follows...

[snip]
// determine what view we are querying
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$id_option = $_POST['D1']; // <=== DING we have winner, notice gets raised
else if ($_SERVER['REQUEST_METHOD'] == 'GET')
$id_option = $_GET['D1'];

if (($id_option == 0) || ($id_option > $id_text_count)) {$id_option = 1;}
$selectID = $id_view[$id_option];
?>

As you can see, there is nothing but good php there.


Yes, it looks fine.
Now, here's where I get pissed off. You all assumed that I was just
pissing in the wind. I gave a good explanation of what I was doing
before and this code tells you nothing more.

Next time, ask for answers before being an ass and assuming you are
working with a n00b..


Sorry I couldn't be more sensitive in my wording, but I think you are being
a bit touchy. For the record, I didn't think you were a n00b, just one of
those guys with an infinite faith in their own infallibility, who
apparently get all huffy at the mere suggestion that they made an error.


Touchy? I don't think so.

Is there any error in the code? If there is, by all means point it out.
That *is* the point behind posting it.

You seem to be on the track that I am trying to find fault here, which
is an error. I am not. So get over that.

I am simply trying to understand the behavior.

If you find it to be some funky bug in PHP, then I will unreservedly
apologize for anything you find fit. Alternatively when you find it to be
some banal mistake in your code, I hope you'll find it in you to forgive my
bruteness.


I still don't have an answer to the original query though.

As it stands, the app works and I may very well be being quite pedantic
about the whole mess but I would like some insight as to why the notice
is thrown. Which was the whole point behind this thread.

I showed the code that was throwing the notice and you (or anyone else)
have shed no light on the problem. I don't know what else I can do or
show to make it any clearer what is happening.

Maybe we both need to steer clear of the fan.

Craig
Jun 10 '06 #12
Craig Morrison wrote:
[snip]
Touchy? I don't think so.

Is there any error in the code? If there is, by all means point it out.
That *is* the point behind posting it.
I allready did point out what I thought, but you'll probably just call me an
ass again, if I repeat it.

You seem to be on the track that I am trying to find fault here, which
is an error. I am not. So get over that.

I am simply trying to understand the behavior.


I don't understand why you think there is a "behavior". There is nothing
exotic in what you are trying to do. Too common a task, for there to be an
oddity that everybody else is missing.

If you find it to be some funky bug in PHP, then I will unreservedly
apologize for anything you find fit. Alternatively when you find it to be
some banal mistake in your code, I hope you'll find it in you to forgive
my bruteness.


I still don't have an answer to the original query though.

As it stands, the app works and I may very well be being quite pedantic
about the whole mess but I would like some insight as to why the notice
is thrown. Which was the whole point behind this thread.

I showed the code that was throwing the notice and you (or anyone else)
have shed no light on the problem. I don't know what else I can do or
show to make it any clearer what is happening.


You present your conclusions of what is happening and pieces of code you say
is involved. No offense meant, but I can't take that as certainty. I really
don't know any other way of putting it than, you must have overlooked
something, doing something or making assumptions that you consider
unimportant. If this pisses you off, then by all means call me a moron, and
I shall not bother you again.
/Bent
Jun 10 '06 #13
Message-ID: <wL******************************@insightbb.com> from Craig
Morrison contained the following:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$id_option = $_POST['D1']; // <=== DING we have winner, notice gets raised


Dumb question. You get the notice /after/ the form is posted?

Have you tried
$id_option =(isset($_POST['D1'])? $_POST['D1'] : "";


--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 10 '06 #14
Message-ID: <io********************************@4ax.com> from Geoff
Berrow contained the following:
Have you tried
$id_option =(isset($_POST['D1'])? $_POST['D1'] : "";


sorry..
$id_option =(isset($_POST['D1'])? $_POST['D1'] : 1;

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 10 '06 #15
Bent Stigsen wrote:
Craig Morrison wrote:
[snip]
Touchy? I don't think so.

Is there any error in the code? If there is, by all means point it out.
That *is* the point behind posting it.


I allready did point out what I thought, but you'll probably just call me an
ass again, if I repeat it.

You seem to be on the track that I am trying to find fault here, which
is an error. I am not. So get over that.

I am simply trying to understand the behavior.


I don't understand why you think there is a "behavior". There is nothing
exotic in what you are trying to do. Too common a task, for there to be an
oddity that everybody else is missing.

If you find it to be some funky bug in PHP, then I will unreservedly
apologize for anything you find fit. Alternatively when you find it to be
some banal mistake in your code, I hope you'll find it in you to forgive
my bruteness.

I still don't have an answer to the original query though.

As it stands, the app works and I may very well be being quite pedantic
about the whole mess but I would like some insight as to why the notice
is thrown. Which was the whole point behind this thread.

I showed the code that was throwing the notice and you (or anyone else)
have shed no light on the problem. I don't know what else I can do or
show to make it any clearer what is happening.


You present your conclusions of what is happening and pieces of code you say
is involved. No offense meant, but I can't take that as certainty. I really
don't know any other way of putting it than, you must have overlooked
something, doing something or making assumptions that you consider
unimportant. If this pisses you off, then by all means call me a moron, and
I shall not bother you again.
/Bent


Why don't you just say that you don't know?

Or is it that you just feel a need to be verbose for no reason?

Here is the entire mess of code.. You tell me why the notice is thrown
if you can, otherwise shut the fuck up.

<!---------- begin index.php ---------->

<?
include 'inc/config.inc.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Stroud Group - Per Month Email Statistics : <? echo
$id_text[$id_option]; ?></title>
<style type="text/css">
<!--
div.cen_page { margin: auto; width: 428px; }
div.copy { margin: auto; text-align: center; }

img.chart { border: 1px solid black; }

table.outer { border: solid 1px #000000; }
table.inner { border-collapse: collapse; margin: 1px; }

th { border-bottom: 1px solid #000000; text-align: left;
background-color: #CCCCCC; }

th.no { width: 15%; text-align: center; }
td.no { width: 15%; text-align: right; padding-right: 10px; }

th.mo { width: 25%; }
td.mo { width: 25%; text-indent: 3px; }

th.us { width: 40%; }
td.us { width: 40%; text-indent: 3px; }

th.mb { width: 20%; text-align: center; }
td.mb { width: 20%; text-align: right; padding-right: 20px; }

tr, td, th { padding: 1px 0px 2px 0px; }

td#trline { border-top: 3px double #000000; border-bottom: 1px solid
black; }

#odd { background: #DDDDDD; }

body, tr, td, th, select, option, input { font-family: Verdana, Geneva,
Arial, Helvetica, sans-serif; font-size: 9px; }

/* IE hack for option vertical centering */
* html input { padding-top:10px; }

input.img { margin-bottom: -3px; }

/* IE hack for img button vertical centering */
* html input.img { margin-bottom: -2px; }

-->
</style>
<script language="javascript">
function nav () {
document.form_data.submit();
}
</script>
</head>
<body>
<div class="cen_page">
<img style="border: none; float: left;" src="images/stroud-logo-big.gif">
<div style="float: right;">
<form method="POST" action="<? echo $_SERVER['PHP_SELF'];?>"
name="form_data">
<p><select size="1" name="D1" onChange="nav();">
<?
for ($i=1; $i <= $id_text_count; $i++) {
print "<option ";
if ($id_option == $i)
print "SELECTED ";
print "value='$i'>" . $id_text[$i] . "</option>\n";
}
?>
</select><input class="img" type="image" src="images/go.ico"
value="Submit" alt="Submit" name="B1"></p>
</form>
</div>
<?php
$db="mailstats";
$link = mysql_connect(...);

if (! $link) die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM $selectID" ) or die("SELECT Error:
".mysql_error());

$fc = mysql_num_fields($result);
$tab_width = $fc * 105; // 420 / 4 = 105, so that's a baseline
print '<br style="clear: both;">';
print "<table class='outer'><tr><td>\n";
print "<table class='inner' width='".$tab_width."px'>\n";
print "<tr>\n";
for ($i=0; $i<$fc; $i++) {
$col_style[$i] = $fc_col_styles[mysql_field_name($result, $i)];
print "<th class='".$col_style[$i]."'>" . mysql_field_name($result, $i)
.. "</th>\n";
}
print "</tr>\n";
$i = 0;
while ($get_info = mysql_fetch_row($result)){
$i++;
if (($i & 1) == 1)
print "<tr>\n";
else
print "<tr id='odd'>\n";
$j = 0;
foreach ($get_info as $field) {
if ($j == 0) {
$fval = number_format($field, 0);
printf("\t<td class='%s'>%s</td>\n", $col_style[$j], $fval);
$tot_sent += $field;
}
else if ($j == 3) {
$fval = number_format($field, 2);
printf("\t<td class='%s'>%s</td>\n", $col_style[$j], $fval);
$tot_mb += $field;
}
else
print "\t<td class='".$col_style[$j]."'>$field</td>\n";
$j++;
}
print "</tr>\n";
}
$i++;
if (($i & 1) == 1)
print "<tr>\n";
else
print "<tr id='odd'>\n";
print "<td id='trline' class='no'>" . number_format($tot_sent, 0) .
"</td><td id='trline'>&nbsp;</td><td id='trline'>&nbsp;</td><td
id='trline' class='mb'>" . number_format($tot_mb, 2) . "</td></tr>\n";
print "</table>\n";
print "</td></tr></table>\n";
mysql_close($link);
?>
<div class="copy">
<p>
<a target="_blank" href="mailchart.php?D1=<? echo $id_option; ?>"><span
title="Click to view full size chart"><img class="chart" alt="Click to
view full size chart" src="mchartinc.php?D1=<? echo $id_option;
?>"></span></a><br>
</form>
<p>Copyright &copy; 2006. Nigel Frankcom &amp; Craig Morrison. All
rights reserved.</p>
</div>
</div>
</body>
</html>

<!---------- begin config.inc.php ---------->

<?
// define query titles
$id_text[1]="Group Total Sent &amp; Received";
$id_text[2]="EU Total Sent &amp; Received";
$id_text[3]="EU Total Sent";
$id_text[4]="EU Total Received";
$id_text[5]="EU Sent By User";
$id_text[6]="EU Received By User";
$id_text[7]="US Total Sent &amp; Received";
$id_text[8]="US Total Sent";
$id_text[9]="US Total Received";
$id_text[10]="US Sent By User";
$id_text[11]="US Received By User";
$id_text[12]="All Domains";

// define view names
$id_view[1]="GroupTotal";
$id_view[2]="EUTotal";
$id_view[3]="EUAllSent";
$id_view[4]="EUAllRcvd";
$id_view[5]="EUSent";
$id_view[6]="EURcvd";
$id_view[7]="USTotal";
$id_view[8]="USAllSent";
$id_view[9]="USAllRcvd";
$id_view[10]="USSent";
$id_view[11]="USRcvd";
$id_view[12]="AllDomainsTotal";

// define column styles
$fc_col_styles['TOTAL'] = 'no';
$fc_col_styles['Total'] = 'no';
$fc_col_styles['SENT'] = 'no';
$fc_col_styles['Sent'] = 'no';
$fc_col_styles['RCVD'] = 'no';
$fc_col_styles['Rcvd'] = 'no';
$fc_col_styles['Month'] = 'mo';
$fc_col_styles['MONTH'] = 'mo';
$fc_col_styles['User'] = 'us';
$fc_col_styles['USER'] = 'us';
$fc_col_styles['MBytes'] = 'mb';
$fc_col_styles['MBYTES'] = 'mb';

// set default values
$id_text_count = 12;
$id_option = 1;

// determine what view we are querying
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$id_option = $_POST['D1'];
else if ($_SERVER['REQUEST_METHOD'] == 'GET')
$id_option = $_GET['D1'];

//print_r($_POST);

if (($id_option == 0) || ($id_option > $id_text_count)) {$id_option = 1;}
$selectID = $id_view[$id_option];

?>

<!---------- begin mailchart.php ---------->

<?
include('./inc/config.inc.php');
include('charts/libchart/libchart.php');

$db="mailstats";
$link = mysql_connect(...);
if (! $link) die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM $selectID" ) or die("SELECT Error:
".mysql_error());

header("Content-Type: image/png");

$user_chart = 0;
$y = 400;
$x = 600;
$f = 10;
$logo_img = dirname(__FILE__) . '/images/stroud-logo-big.png';
if (($id_option == 5) || ($id_option == 6) || ($id_option == 10) ||
($id_option == 11) || ($id_option == 12)) {
$y = 1400;
$x = 400;
$f = 7;
$logo_img = dirname(__FILE__) . '/images/stroud-logo-small.png';
$user_chart = 1;
}
if ($id_option == 1)
$chart = new PieChart($x,$y,$f);
else
$chart = new HorizontalChart($x,$y,$f);

// mdata = array of field stuff
// 0 = total
// 1 = month
// 2 = user/group
// 3 = mbytes
while ($mdata = mysql_fetch_row($result)){
if ($user_chart)
$chart->addPoint(new Point($mdata[1] . " - " . $mdata[2], $mdata[0]));
else
$chart->addPoint(new Point(($id_option != 1) ? $mdata[1] : $mdata[1] .
" : " . $mdata[0], $mdata[0]));
}

$chart->setLogo($logo_img);
$chart->setTitle(str_replace("&amp;", "&", $id_text[$id_option]));
$chart->render();

mysql_close($link);
?>

<!---------- begin mchartinc.php ---------->
<?
include('./inc/config.inc.php');
include('charts/libchart/libchart.php');

$db="mailstats";
$link = mysql_connect(...);
if (! $link) die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM $selectID" ) or die("SELECT Error:
".mysql_error());

header("HTTP/1.1 200 OK");
header("Cache-Control: no-cache");
header("Content-Type: image/png");
header("Content-Disposition: attachment; filename=stroudchart.png");

$user_chart = 0;
$y = 200;
$x = 300;
$f = 4;
$logo_img = dirname(__FILE__) . '/images/stroud-logo-small.png';
if (($id_option == 5) || ($id_option == 6) || ($id_option == 10) ||
($id_option == 11)) {
$y = 200;
$x = 300;
$f = 4;
$user_chart = 1;
}
if ($id_option == 1)
$chart = new PieChart($x,$y,$f);
else
$chart = new HorizontalChart($x,$y,$f);

// mdata = array of field stuff
// 0 = total
// 1 = month
// 2 = user/group
// 3 = mbytes
$i = 0;
while ($mdata = mysql_fetch_row($result)){
$chart->addPoint(new Point($mdata[1], $mdata[0]));
$i++;
if ($i > 8)
break;
}

$chart->setLogo($logo_img);
$chart->setTitle(str_replace("&amp;", "&", $id_text[$id_option]));
$chart->render();

mysql_close($link);
?>

I have left *nothing* out, so now, if you or anyone else can please tell
me why the notice is thrown.

--
Craig Morrison
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
http://pse.2cah.com
Controlling pseudoephedrine purchases.

http://www.mtsprofessional.com/
A Win32 email server that works for You.

Jun 10 '06 #16
Craig Morrison wrote:
[snip]
Why don't you just say that you don't know?

Or is it that you just feel a need to be verbose for no reason?

Here is the entire mess of code.. You tell me why the notice is thrown
if you can, otherwise shut the fuck up.
Oh, sticks and stones Craig, I am too old to care about your huffing and
puffing. And you are free to ignore anything I say.

The notice get thrown because there is an undefined index, just as the
notice says, but I can't tell you the exact circumstances. For that, I
would have to look over your shoulder, and see exactly how the things are
used and what comes out of it, and not just the things you find relevant to
tell. If it was visible from that, you would probably have seen it.

What I do know (or atleast put my reputation on the line for), is that if
the form posts the D1 value, as you say it does, then there is *no way*
that $_POST['D1'] is generating a notice. Period.
That is why I said you should treat it as a bug/flaw somewhere in your
construction, because effectively it would mean that you had an unhandled
state. But from your code you posted, I can see that you verify the value
afterwards, so it is not critical.

What Geoff suggest (using isset before accessing the value) lets you decide
what to do in cases where the value is not set. That will remove the
clutter from your log-files.

[snip code]
Ok, seen it.
I have left *nothing* out, so now, if you or anyone else can please tell
me why the notice is thrown.


Just a few things.
What is the exact full message (notice) you get.
How is the index.php page initially accessed. (get/post, args)

/Bent
Jun 10 '06 #17
>Here is the entire mess of code.. You tell me why the notice is thrown
if you can, otherwise shut the fuck up.


I tried setting this up on my server. When I browse to the
directory it's set up in, I get the undefined index notice
*BEFORE* the form appears (and I don't submit the form at all).

Unless I am invoking it incorrectly (is index.php supposed to be
called from ANOTHER form?) you're not taking into account that
config.inc.php is called just to throw up the form as well as
for submitting it.

I also get database errors because your queries don't work too
well on an empty database I pointed the page at. I don't need
your tables to reproduce the problem.

Gordon L. Burditt
Jun 10 '06 #18
Gordon's thought is the same as mine. The only reason I can see it
raising a notice is if it is accessing the index when no data was
post/get'ed to the web page, which would be the case when the form
first appears. Simply use one of the previous replies which suggests
using isset().


Gordon Burditt wrote:
Here is the entire mess of code.. You tell me why the notice is thrown
if you can, otherwise shut the fuck up.


I tried setting this up on my server. When I browse to the
directory it's set up in, I get the undefined index notice
*BEFORE* the form appears (and I don't submit the form at all).

Unless I am invoking it incorrectly (is index.php supposed to be
called from ANOTHER form?) you're not taking into account that
config.inc.php is called just to throw up the form as well as
for submitting it.

I also get database errors because your queries don't work too
well on an empty database I pointed the page at. I don't need
your tables to reproduce the problem.

Gordon L. Burditt


Jun 11 '06 #19
Craig Morrison schrieb:

[...]
Why don't you just say that you don't know?

Or is it that you just feel a need to be verbose for no reason?

Here is the entire mess of code.. You tell me why the notice is thrown
if you can, otherwise shut the fuck up.
You might understand that people will not take their time to answer your
questions if you stick to this style of posting. Also keep in mind that
newsgroups are archieved by Google, and thus everything you write will
be accessible in the future for anybody having any interests about your
personality, i.e. recruiters of companies where you apply for a job.

http://groups.google.ch/groups/profi...DuwKz324rebT9g
shows that you are quite new to newsgroups; you might want to read some
pages on netiquette. (I remember to have made some postings I am not
proud of when I first started to post to newsgroups, so I know what I
write about.) If you think some people are being rude in their comments,
then keep in mind that it is you asking for help, and they tell you that
you do this the wrong way - being told about the rules of usenet is a
form of help you should appreciate. If you want to get help on your
problems for free, you have to respect those people reading and
commenting your posts.

[snipped a lot of code]
I have left *nothing* out, so now, if you or anyone else can please tell
me why the notice is thrown.


I write this during my time that I am not paid for by anyone. Nobody in
this group has the duty to care for your problem. So instead of posting
either no code at all or the "entire mess", it might be a more
successful approach to track down the problem to it's essential parts.
Write a script only with the essential functionality, i.e.

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
$id_option = $_POST['D1'];
else if ($_SERVER['REQUEST_METHOD'] == 'GET')
$id_option = $_GET['D1'];
print_r($_POST);
?>
<html>
<head></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="D1" value="<?php echo $id_option; ?>">
<input type="submit" value="View Chart">
</form>
</body>
</html>

Now if the output of print_r shows that $_POST['D1'] is set, but line 3
still throws a notice, then your question is correct. In this example
you find that the notice is thrown at line 12 in the case that the form
has not been posted yet.
Maybe this shows your problem, otherwise add more parts of your code
until the problem occurs. You can also remove parts of your
functionality until the error disappears, or var_dump() the variables
step by step.
At the end, you either find your mistake yourself, or then you know the
appropriate question to ask, and have the appropriate code to post.

Yes this is a lot of work, but it makes a base for friendly people to
help you. Alternatively you can hire some PHP crack to solve your
problems, but you won't get them solved for free if you keep shouting at
the people you expect help from!

--
Markus
Jun 12 '06 #20
Markus Ernst wrote:
Craig Morrison schrieb:

[...]
Why don't you just say that you don't know?

Or is it that you just feel a need to be verbose for no reason?

Here is the entire mess of code.. You tell me why the notice is thrown
if you can, otherwise shut the fuck up.
You might understand that people will not take their time to answer your
questions if you stick to this style of posting.


It doesn't make people shut up either. :)

To be fair, his original post was quite polite.

Also keep in mind that
newsgroups are archieved by Google, and thus everything you write will
be accessible in the future for anybody having any interests about your
personality, i.e. recruiters of companies where you apply for a job.

http://groups.google.ch/groups/profi...DuwKz324rebT9g shows that you are quite new to newsgroups; you might want to read some
pages on netiquette. (I remember to have made some postings I am not
proud of when I first started to post to newsgroups, so I know what I
write about.)
When going head first into a mass of people from widely different cultures,
many trying to convey their message in a foreign language, then I think
some initial conflicts is what can be expected, regardless of the person.

And people change. If someone made some mistakes and they learned from them,
then that's a sign of a very good quality in a person.

IMO, people who don't understand that, are not worth pleasing or working
for.

If you think some people are being rude in their comments,
then keep in mind that it is you asking for help, and they tell you that
you do this the wrong way - being told about the rules of usenet is a
form of help you should appreciate. If you want to get help on your
problems for free, you have to respect those people reading and
commenting your posts.


I think his basic problem was, that he didn't expect help. In his mind, his
scripts didn't have problems, rather PHP had a strange behavior.
If only he had put a little effort into trying to understand what we were
trying to say. I thought your first suggestion was a clear and polite hint
that he should track down the problem in his code.

Anyway, it's not like one can demand what one wants, only hope to get what
one needs.
/Bent
[snip]
Jun 13 '06 #21
Bent Stigsen schrieb:
http://groups.google.ch/groups/profi...DuwKz324rebT9g
shows that you are quite new to newsgroups; you might want to read some
pages on netiquette. (I remember to have made some postings I am not
proud of when I first started to post to newsgroups, so I know what I
write about.)

When going head first into a mass of people from widely different cultures,
many trying to convey their message in a foreign language, then I think
some initial conflicts is what can be expected, regardless of the person.

And people change. If someone made some mistakes and they learned from them,
then that's a sign of a very good quality in a person.

IMO, people who don't understand that, are not worth pleasing or working
for.


Yes... I was actually argueing with people trying to tell me not to
top-post and to use a correct sig delimiter... :-) There are actually 2
communication problems about this stuff in usenet:
1. People who tell newbies they are assholes instead of just pointing
them the right direction
2. Newbies who assume they are told to be assholes even if they are
politely pointed to the right direction...

--
Markus
Jun 13 '06 #22
Markus Ernst wrote:
[snip]
Yes... I was actually argueing with people trying to tell me not to
top-post and to use a correct sig delimiter... :-) There are actually 2
communication problems about this stuff in usenet:
1. People who tell newbies they are assholes instead of just pointing
them the right direction
2. Newbies who assume they are told to be assholes even if they are
politely pointed to the right direction...


It's one of those things I can't figure out. Even without the aspects of
vanity, selfishness or rudeness, it is allways tempting to consider ones
own views and ideals as ultimately correct, which I straight off would
think made it very doubtful, that a person would change his ways merely
presented with a polite suggestion. (both ways)

It would have been easy, if the "rules" had been all facts and numbers, but
they aren't. People come in from a world of liberal thinking, individualism
and cut-throat competition. Much different than the ideas of uniformity and
altruism on the net. It is two worlds with widely different definitions of
"common sense" and efficiency.

If people don't readily believe it (whatever "we" make up), then without the
means of persuasion by appeal to facts or common sense, what else is there
than to just generally make it unpleasant to disagree, and in return expect
any reasonable person to object to that.

Then again, who would deny sinners a fair chance to repent. :)

--
/Bent
Jun 15 '06 #23
<snip>

I had the same problem. Page 1 uses an image map (the layout of booths
at a festival). Depending on where you click it calls page 2, sending it
the booth number you selected popping up a new window with the booth
number preselected. (ooooooooo)

<.in.Javascript...>(page booth1.php)
url = "booth2.php?" + "booth=" + booth;
win4 = window.open (url ,"", option);

:-O Notice :-O Notice ... Notice
(oh shutup)
So I added the ?missing? items.
url = "booth2.php?" + "booth=" + booth +
"&name=&address=&phone=&email=&comment=";
win4 = window.open (url ,"", option);

The silence is deafening :-D

As an aside - Why da flip did someone decide that the "Notice" needed to
be spit out is beyond me. And shouldn't (is) there be a way to say
"Shhhhhhhh" IE "<?php -quite"
Jun 15 '06 #24
Cal Lidderdale schrieb:
As an aside - Why da flip did someone decide that the "Notice" needed to
be spit out is beyond me.
This is actually a service for you. Imagine writing an application with
some 1000s of lines of code, and at the end you just get a blank page -
I bet you would be quick in blaming PHP for letting you stand in the rain.
And shouldn't (is) there be a way to say "Shhhhhhhh" IE "<?php -quite"


If parameters are are optional it is quite easy to code:
$thing = isset($_POST['anything']) ? $_POST['anything'] : false;

If you prefer it the dirty way you can disable any level of error
reporting: www.php.net/error_reporting.

Good luck
Markus
Jun 15 '06 #25
Markus Ernst wrote:
Cal Lidderdale schrieb:
As an aside - Why da flip did someone decide that the "Notice" needed
to be spit out is beyond me.

This is actually a service for you. Imagine writing an application with
some 1000s of lines of code, and at the end you just get a blank page -
I bet you would be quick in blaming PHP for letting you stand in the rain.
And shouldn't (is) there be a way to say "Shhhhhhhh" IE "<?php -quite"

If parameters are are optional it is quite easy to code:


$list = array (name, address, phone);
foreach ($list as $item) {
$$item = isset($_GET["$item"]) ? $_GET["$item"] : false;
}

If you prefer it the dirty way you can disable any level of error
reporting: www.php.net/error_reporting.

Good luck
Markus


Thanks, old dog learn new trick :-D see above

( I tried to find a animated gif of a sweeping bow - ya know, sometimes
the internet stinks - How to tie a sweeping bow - No a bow not a bow. ) :-/
Jun 15 '06 #26
Cal Lidderdale schrieb:

$list = array (name, address, phone);
foreach ($list as $item) {
$$item = isset($_GET["$item"]) ? $_GET["$item"] : false;
}
Should actually display 3 undefined constant notices... change the use
of quotes, quote strings but not variables:

$list = array ('name', 'address', 'phone');
foreach ($list as $item) {
$$item = isset($_GET[$item]) ? $_GET[$item] : false;
}
( I tried to find a animated gif of a sweeping bow - ya know, sometimes
the internet stinks - How to tie a sweeping bow - No a bow not a bow. ) :-/


I am sorry I am not a native English speaker, and I don't understand
exactly what you mean. Anyway smell is a quite common phenomenon
wherever civilisation happens...
Jun 15 '06 #27

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Neil Strong | last post by:
I'm getting an error message "Unidentified Index" when reading posted variables from a form $x = $_POST I know I can use 'isset()' to check them first, but I'm curious as to why this works on...
6
by: Will | last post by:
I downloaded a webcounter from http://www.math.sunysb.edu/~shafikov/computing/webcounter. It seems to be working but I have the following being printed to the page: Notice: Undefined variable:...
1
by: D. Alvarado | last post by:
Hello, Ia m running PHP 4 on Fedora Linus Apache 1.27. Since I have a dev box, I would like warnings to appear in the event of undefined variables or constants. But although I specified this...
7
by: Coder Droid | last post by:
I decided to run some code with errors set to E_ALL, just to see what I would run across. It caught a few things, but 90% or better of the messages were of the 'undefined' kind: PHP Notice: ...
3
by: bissatch | last post by:
Hi, I get the following error: Notice: Undefined variable: end_while in C:\Program Files\Apache\Apache2\htdocs\csp\inc\xmlmenu.php on line 102 This is a script that works on the server...
9
by: petermichaux | last post by:
Hi, I am curious about how php deals with the following situation where I use an undefined index into an array. PHP seems to be behaving exactly how I want it to but I want to make sure that it...
5
by: DavidB | last post by:
Greetings I don't know if this is possible, but this group should be able to tell me. I have a webpage with a changing message board (I understand the problems with having changing text, but...
9
by: java | last post by:
Hey there, I just removed an elderly PHP4-Installation from my Windows-Box and installed PHP 5.2.1. I used the PHP4-Module as local batchfile- interpreter by E:\ersDHCP>php ./extractLog.php ...
6
by: jsgoodrich | last post by:
I am looking for some help if anyone can lend a hand. I have a simple php website that displays a table from my mysql database. To prep for my MCSE I moved my home server to Windows 2003...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.