473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

'Undefined index' notice - what does this mean?

1
i've got this message

Notice: Undefined index: name in c:\program files\easyphp1-8\www\forum\kemaskini.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 5238
ronnil
134 Expert 100+
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 Expert 4TB
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 Expert 1GB
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 Expert 2GB
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
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: ...
4
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: ...
26
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
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...
3
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:...
3
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...
9
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...
5
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 : ...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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,...
0
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...

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.