Solved

undefined variable when it has been declared

Posted on 2002-07-28
11
240 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

708 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

16 Experts available now in Live!

Get 1:1 Help Now