Solved

undefined variable when it has been declared

Posted on 2002-07-28
11
262 Views
Last Modified: 2008-02-26
Hullo,

I got this bizzare error today:

Notice: Undefined variable: submit in c:\inet

i am running IIS php4, mysql3, on win2k pro

i had thought i set things up correctly.

i tried running this exact script on my linux box, and guess what, everytning works fine.  this is a page where i submit stuff to database.  any idea why things are being undeclared while it works fine on other servers??

thnkas
0
Comment
Question by:jwnrb
11 Comments
 
LVL 4

Expert Comment

by:daluu
ID: 7184231
has it been working under Windows? Has IIS, PHP, MySQL under Windows been working successfully? If it isn't a configuration problem on IIS, PHP, or MySQL, then maybe it's your script (and maybe not). Oh and posting the script might be helpful in case it's not a configuration problem.
0
 

Author Comment

by:jwnrb
ID: 7184247
well as i stated before, the script is fine, as i used the same file on a linux server.

i just installed iis / php / mysql with the standard default settings on the installation.

i had formatted my computer and started from scratch, in the past it has worked, yes.

0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7184491
get apache server for windows and try it on that, as dalluu said sould be a prob with m$ servers.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7184763
Let's see the code.

Also, you MAY find that "submit" is expected to come from the HTML code.

Some browsers either don't send, or don't reliably send the form variable for the submit button.

e.g.

<form action="script.php" method="POST">
<input name="name" type="text">
<input name="submit" type="submit">
</form>

Some browsers will not give you submit correctly.

Several options.

1 - Recommend a newer browser.
2 - Add a hidden variable to the form for testing against.

<form action="script.php" method="POST">
<input name="name" type="text">
<input name="submit" type="hidden" value="submit_or_whatever">
<input name="_submit" type="submit">
</form>


You can use _submit (if it is present) or submit.

Regards,

Richard Quadling.
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 50 total points
ID: 7185031
A few things.

1 - $submit will not be available on newer versions of PHP.

Instead you need to use ...

$_POST["submit"]
$_GET["submit"]
$_COOKIE["cookie_name"]
$_SERVER["server_env_var"]

Try ...

if (isset($_POST["submit"]))

and

<form name="form1" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">

and

$query = "INSERT INTO bowler_names (id, fname, lname) VALUES (NULL, '{$_POST["fname"]}', '{$_POS["lname"]}')";

Richard.
0
 

Author Comment

by:jwnrb
ID: 7185325
hmm, i guess the standard changed??  so i guess my IIS server has newer version of php than my redhat server.

lol!

thanks so much
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7185354
Try this on both server to give you a quick idea of the difference in some of the predefined variables.

---------info.php-------------
<?php phpinfo(); ?>

Richard.

P.S. Thanks for the points.
0
 

Author Comment

by:jwnrb
ID: 7185628
ah so the new stuff i just did might not work for my linux box? hmm..i will check out that as well. (i never coded in php before i took this project so i can learn from it!!)
0
 

Author Comment

by:jwnrb
ID: 7185636
linux = 4.1.2
IIS   = 4.2.1

and linux has php_self
while iis has the one you specified.

much thanks again!
0
 
LVL 1

Expert Comment

by:Augusztin
ID: 7188674
You don't have the register_globals at the On state. This directive registers all incoming variables to global variables. Or you can use (this is better) the $_GET, $_POST,... arrays.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question