473,398 Members | 2,335 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,398 software developers and data experts.

Undefined Index

Reference the above thread: "Passing a HTML variable to a PHP file
using include". One thing I've learned over the years is that an error
doesn't always come from where the compiler/interperture says it does.
Case in point maybe.

I am getting this error:
Notice: Undefined index: var1 in
/var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 4

Warning: fwrite(): supplied argument is not a valid stream resource in
/var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 5

Warning: fclose(): supplied argument is not a valid stream resource in
/var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 6

in this function:

<?php
if($_GET["op"] == "ds") {
foreach ($_GET["name"] as $key=>$value) {
$fp=fopen($_GET["var1"],"a");
fwrite($fp,$_GET["name"][$key] ."&nbsp;". $_GET["email"][$key]
.."&nbsp;". $_GET["phone"][$key] ."&nbsp;". $_GET["id"][$key]);
fclose($fp);
}
}
?>

'var1' comes from this last line in this snippet in a previous function:

<html>
<body>
<?php include ($_GET["var2"]); ?// this works
<br clear="all">
<?php include ($_GET["var1"]); ?//this works
<form action="form.php?var1=>($_GET["var1"])" method="GET"// NOT

I have found that the text editor you are using will color out the
parts of code if they are correct. This code does not color out evenly.
In the 2 'include' statements '$_GET' is red. In the 'form action'
statement it is not.

At this point 'var1' is a name on a disk with zero length. Is it
possible that the error trapping of the 'include' function is taking
care of this and the error trapping of the 'fopen' alerts you that it is
going to crash fwrite because 'var1' is now corrupted?

I'm clueless, can anyone help?
Dave
Sep 20 '06 #1
1 2280
"Dave Kelly" <da********@earthlink.netwrote in message
news:0M****************@newsread2.news.pas.earthli nk.net...
Reference the above thread: "Passing a HTML variable to a PHP file
using include". One thing I've learned over the years is that an error
doesn't always come from where the compiler/interperture says it does.
Case in point maybe.

I am getting this error:
Notice: Undefined index: var1 in
/var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 4

Warning: fwrite(): supplied argument is not a valid stream resource in
/var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 5

Warning: fclose(): supplied argument is not a valid stream resource in
/var/www/vhosts/texasflyfishers.org/httpdocs/form.php on line 6

in this function:

<?php
if($_GET["op"] == "ds") {
foreach ($_GET["name"] as $key=>$value) {
$fp=fopen($_GET["var1"],"a");
fwrite($fp,$_GET["name"][$key] ."&nbsp;". $_GET["email"][$key]
."&nbsp;". $_GET["phone"][$key] ."&nbsp;". $_GET["id"][$key]);
fclose($fp);
}
}
?>

'var1' comes from this last line in this snippet in a previous function:

<html>
<body>
<?php include ($_GET["var2"]); ?// this works
<br clear="all">
<?php include ($_GET["var1"]); ?//this works
<form action="form.php?var1=>($_GET["var1"])" method="GET"// NOT

Since the form method is GET, it will replace any existing get parameters in
the form action. Use a hidden field in the form instead:

<input type="hidden" name="var1" value="<?php echo $_GET["var1"] ?>">

Dunno what the heck this var1=>($_GET["var1"]) syntax is, smarty perhaps, I
don't know cos I've never used it, but I assume you understand my example
and can adjust it to meet your requirments..

Get parameters in form action work only if the form method is POST...

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net || Gedoon-S @ IRCnet || rot13(xv***@bhgbyrzcv.arg)
Sep 20 '06 #2

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

Similar topics

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: ...
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...
4
by: John Oliver | last post by:
PHP Notice: Undefined index: name in /home/www/reformcagunlaws.com/new.php on line 6 PHP Notice: Undefined index: address in /home/www/reformcagunlaws.com/new.php on line 7 PHP Notice: ...
9
by: Alan Schroeder | last post by:
The following code produces the expected results on a PC using gcc, but I need to port it (or least something similar) to a different platform/compiler. I don't think I've introduced any undefined...
7
by: deepak | last post by:
Using 'char' as an array index is an undefined behavior?
3
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined...
3
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice:...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
5
by: siyaverma | last post by:
Hi, I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that, After doing some changes when i run it on my...
3
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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,...
0
isladogs
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...

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.