Solved

undefined variable when it has been declared

Posted on 2002-07-28
11
253 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
 
LVL 40

Expert Comment

by:RQuadling
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:
RQuadling 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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:RQuadling
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File submission to SQL Server 1 38
PHP Undefined Index in HTML Form? 2 32
html input type 3 21
Convert html page to a php post email form automatically? 10 27
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now