Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

undefined variable when it has been declared

Posted on 2002-07-28
11
Medium Priority
?
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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.
Suggested Courses

730 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