Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

undefined variable when it has been declared

Posted on 2002-07-28
11
Medium Priority
?
286 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

971 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