PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 27th, 2000, 11:00 PM
zon zon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 4 zon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i copied & paste an example from webmonkey and get this error on th browser:

'Warning: Uninitialized variable or array index or property (submit) in /home/httpd/html/php/dbform3.php3 on line 4'

the code:
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root","trickle");
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";
$result = mysql_query($sql);

echo "Thank you! Information entered.n";
} else{

// display form
?>

<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Address:<input type="Text" name="address"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Enter information">
</form>

<?php
} // end if
?>

</body>
</html>


how do I get rid off the warning message?

tia.

Reply With Quote
  #2  
Old April 28th, 2000, 05:50 AM
closecut closecut is offline
worshipper of DOT
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Halmstad, Sweden
Posts: 35 closecut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 5 m 13 sec
Reputation Power: 14
Send a message via ICQ to closecut
The reason you get the error is that the first time you fire up the script, the $submit-variable isn't set ..

try

if (isset($submit))

instead ..

forgive if i'm totally wrong ..



------------------
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Linux, the operating system with a clue - Command Line User Environment.[/quote]

geeee... thanks!

/closecut

Reply With Quote
  #3  
Old April 28th, 2000, 06:11 AM
zon zon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 4 zon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by closecut:
The reason you get the error is that the first time you fire up the script, the $submit-variable isn't set ..

try

if (isset($submit))

instead ..

forgive if i'm totally wrong .. URL


[/quote]

COOL. it works.

thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > uninitialized variable

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap