473,800 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'Undefined index' notice - what does this mean?

1 New Member
i've got this message

Notice: Undefined index: name in c:\program files\easyphp1-8\www\forum\kem askini.php on line 2

i've used this coding..

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $name = $_POST['name'];
  3.     $date = $_POST['date'];
  4.     $time = $_POST['time'];
  5.     $email = $_POST['email'];
  6.     $comment = $_POST['comment'];
  7.  
  8. $conn = mysql_connect("localhost","root","");
  9. if (!$conn)
  10.   {
  11.   die('Could not connect: ' . mysql_error());
  12.   }
  13.  
  14. $db=mysql_select_db("forum", $conn);
  15.  
  16. $query = "UPDATE ruang_forum 
  17.           SET date='$date', time='$time', email='$email', comment='$comment'
  18.  WHERE name='$name'";
  19.  
  20. if($query)
  21. {
  22.   echo '';
  23.     }
  24.     else
  25.     echo 'Error....';
  26.  
  27. $result = mysql_query($query); 
  28. mysql_close($conn);
  29. ?>
  30. <html><head><title>forum</title><body>
  31.  
  32. <p><a href="http://127.0.0.1/forum/main2.html">Home</a></p>  <br>
  33. </body></head></html>
[Please use CODE tags when posting source code. Thanks! --pbmods]

can anybody help me to solve this problem?? tq :)
Jul 2 '07 #1
4 5265
ronnil
134 Recognized Expert New Member
you get the error because the $_POST variable has not been set. In other words, the form has not yet been submitted.

What you need to do is a statement that checks if the variable has been set. isset() is probably the best way to do this.

if(isset($_POST['name']))
{
//your form has been submitted and you can go on executing you query message.
}

it is probably a good idea to do this with all your variables, assuring that the user has submitted anything.

If you just want to remove the error, you can put an @ before $_POST['name']

the @ silences any errors made by $_POST
Jul 2 '07 #2
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles contain only one word. such as, 'error' actually get FEWER responses?).
Jul 2 '07 #3
kovik
1,044 Recognized Expert Top Contributor
If you just want to remove the error, you can put an @ before $_POST['name']

the @ silences any errors made by $_POST
As a side-note, the second method is not recommended, but it is completely possible. Suppressing error messages is only useful before you know how to use try...catch statements on functions that deal with file handling or database connections. Also, the only other acceptable time to use it is if the error message would display private information that could compromise security.
Jul 2 '07 #4
Motoma
3,237 Recognized Expert Specialist
As others have said, your form did not post a 'name' variable. Remember, array indexes are case sensitive, so $_POST['name'] and $POST['Name'] are different fields.
Jul 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2815
by: Coder Droid | last post by:
I decided to run some code with errors set to E_ALL, just to see what I would run across. It caught a few things, but 90% or better of the messages were of the 'undefined' kind: PHP Notice: Undefined variable PHP Notice: Undefined index PHP Notice: Undefined property I'd like to go back and fix what I can, but I'm wondering: how good or bad is this? I mean, I rely on the fact that the first use of a variable
4
7196
by: John Oliver | last post by:
PHP Notice: Undefined index: name in /home/www/reformcagunlaws.com/new.php on line 6 PHP Notice: Undefined index: address in /home/www/reformcagunlaws.com/new.php on line 7 PHP Notice: Undefined index: city in /home/www/reformcagunlaws.com/new.php on line 8 PHP Notice: Undefined index: county in /home/www/reformcagunlaws.com/new.php on line 9 PHP Notice: Undefined index: zip in /home/www/reformcagunlaws.com/new.php on line...
26
3754
by: Craig Morrison | last post by:
I'm getting this: PHP Notice: Undefined index: D1 in /var/www/html..... From this line of code: $id_option = $_POST; Which is posted by this:
3
4967
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined index: abdatum in /zipcode.php on line 13 Notice: Undefined index: zimmer in /zipcode.php on line 14 Notice: Undefined index: city in /zipcode.php on line 39 Notice: Undefined index: state in /zipcode.php on line 41
3
5505
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email...
3
3878
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if (empty($info)) { $info='noinfo'; } changeinfo($info); Hey everyone, I keep getting an error regarding the above code. These are the errors: Notice: Undefined index: channels in /home/forcefed/public_html/index.php on line 5
9
32507
by: simple12 | last post by:
Hello I have a script which have the facility of entering any code to some part of a webpage. I have some problems with it. When i put some code in the script then their is no error shown. When i try to not use a code and leave it empty the following php errors happens. I dont understand why. Help me. Error shown are: - PHP Notice: in file /index.php on line 132: Undefined offset: 4 PHP Notice: in file /index.php on line 141:...
5
7369
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : $http_ref= $HTTP_REFERER; $prog = $_COOKIE;
2
4590
by: Smellydog | last post by:
I'm having a strange issue with PHP version 5.2.8 running on Windows Vista with Lighttpd. I receive a Notice that says the following: Notice</b>: Undefined index: name in <b>E:\LightTPD\htdocs\go\go\form.php</b> on line <b>160</b> Here is the odd part. No matter what I do, no matter how many times I change the script, add lines, remove lines, the notice keeps referencing the same file and line number. Even when I comment out the line,...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.