473,396 Members | 1,987 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,396 software developers and data experts.

database error.....undefined index

anfetienne
424 256MB
i take information from a database and then have the collected values entered into a form with hidden fields.

Expand|Select|Wrap|Line Numbers
  1.   <input type="hidden" name="returnURL" id="returnURL" value="<?php print $returnURL;?>"/>      
  2.   <input type="hidden" name="tempID" id="tempID" value='<?php print $random_digit;?>'/> 
  3.   <input type="hidden" name="htmlcss" id="htmlcss" value='<?php print $htmlcss;?>'/>      
  4.   <input type="hidden" name="header" id="header" value='<?php print $header;?>'/>
  5.   <input type="hidden" name="nav" id="nav" value='<?php print $nav;?>'/>      
  6.   <input type="hidden" name="titleWrap01" id="titleWrap01" value='<?php print $titleWrap01;?>'/> 
  7.   <input type="hidden" name="titleWrap02" id="titleWrap02" value='<?php print $titleWrap02;?>'/>      
  8.   <input type="hidden" name="subheadWrap01" id="subheadWrap01" value='<?php print $subheadWrap01;?>'/>
  9.   <input type="hidden" name="subheadWrap02" id="subheadWrap02" value='<?php print $subheadWrap02;?>'/>      
  10.   <input type="hidden" name="flashWrap01" id="flashWrap01" value='<?php print $flashWrap01;?>'/> 
  11.   <input type="hidden" name="flashWrap02" id="flashWrap02" value='<?php print $flashWrap02;?>'/>      
  12.   <input type="hidden" name="flash01" id="flash01" value='<?php print $flashURL;?>'/>
  13.   <input type="hidden" name="flashVar" id="flashVar" value='<?php print $flashVar;?>'/>      
  14.   <input type="hidden" name="flash02" id="flash02" value='<?php print $flash02;?>'/> 
  15.   <input type="hidden" name="flashWrap03" id="flashWrap03" value='<?php print $flashWrap03;?>'/>      
  16.   <input type="hidden" name="descriptionWrap01" id="descriptionWrap01" value='<?php print $descriptionWrap01;?>'/>
  17.   <input type="hidden" name="descriptionWrap02" id="descriptionWrap02" value='<?php print $descriptionWrap02;?>'/>      
  18.   <input type="hidden" name="generalWrap01" id="generalWrap01" value='<?php print $generalWrap01;?>'/> 
  19.   <input type="hidden" name="generalWrap02" id="generalWrap02" value='<?php print $generalWrap02;?>'/>      
  20.   <input type="hidden" name="aboutWrap01" id="aboutWrap01" value='<?php print $aboutWrap01;?>'/>
  21.   <input type="hidden" name="aboutWrap02" id="aboutWrap02" value='<?php print $aboutWrap02;?>'/>      
  22.   <input type="hidden" name="paymentWrap01" id="paymentWrap01" value='<?php print $paymentWrap01;?>'/> 
  23.   <input type="hidden" name="paymentWrap02" id="paymentWrap02" value='<?php print $paymentWrap02;?>'/>
  24.   <input type="hidden" name="termsWrap01" id="termsWrap01" value='<?php print $termsWrap01;?>'/>      
  25.   <input type="hidden" name="termsWrap02" id="termsWrap02" value='<?php print $termsWrap02;?>'/>
  26.   <input type="hidden" name="footer" id="footer" value='<?php print $footer;?>'/> 
  27.  
when i submit the form with all the other text fields filled out......then in the file to save it to a database it brings up the error....."undefined index" although i only have 1 index set.

Expand|Select|Wrap|Line Numbers
  1. <?PHP error_reporting(E_ALL);
  2. $username="tempsUser";
  3. $password="auction";
  4. $database="auctionTemps";
  5.  
  6. $returnURL = $_POST['returnURL'];
  7.  
  8. $tempID=$_POST['tempID'];
  9. $htmlcss=$_POST['htmlcss'];
  10. $header=$_POST['header'];
  11. $nav=$_POST['nav'];
  12. $titleWrap01=$_POST['titleWrap01'];
  13. $title=$_POST['title'];
  14. $titleWrap02=$_POST['titleWrap02'];
  15. $subheadWrap01=$_POST['subheadWrap01'];
  16. $subheading=$_POST['subheading'];
  17. $subheadWrap02=$_POST['subheadWrap02'];
  18. $flashWrap01=$_POST['flashWrap01'];
  19. $flashWrap02=$_POST['flashWrap02'];
  20. $flash01=$_POST['flash01'];
  21. $flashVar=$_POST['flashVar'];
  22. $flash02=$_POST['flash02'];
  23. $flashWrap03=$_POST['flashWrap03'];
  24. $descriptionWrap01=$_POST['descriptionWrap01'];
  25. $description=$_POST['description'];
  26. $descriptionWrap02=$_POST['descriptionWrap02'];
  27. $generalWrap01=$_POST['generalWrap01'];
  28. $general=$_POST['general'];
  29. $generalWrap02=$_POST['generalWrap02'];
  30. $aboutWrap01=$_POST['aboutWrap01'];
  31. $about=$_POST['about'];
  32. $aboutWrap02=$_POST['aboutWrap02'];
  33. $paymentWrap01=$_POST['paymentWrap01'];
  34. $payment01=$_POST['payment01'];
  35. $payment02=$_POST['payment02'];
  36. $paymentWrap02=$_POST['paymentWrap02'];
  37. $termsWrap01=$_POST['termsWrap01'];
  38. $terms=$_POST['terms'];
  39. $termsWrap02=$_POST['termsWrap02'];
  40. $footer=$_POST['footer'];
  41. ?>
  42.  
  43. <?
  44.  
  45. // OPEN CONNECTION ---> 
  46. $connection=mysql_connect("localhost" ,"$username", "$password") or die("Unable to connect!");
  47.  
  48. mysql_select_db("$database") or die("Unable to select database!");
  49.  
  50. // Select column 1 from table name where column name = $your_var.
  51. $sql = "SELECT tempID FROM savedTemps WHERE tempID = '{$tempID}'";
  52. // If mysql_query returns false, we'll die with the error.
  53. $res = mysql_query( $sql ) or die( mysql_error() );
  54.  
  55. // If a there is a match
  56. if ( mysql_num_rows( $res ) > 0 )
  57. {
  58. //  EXECUTE QUERY ---> 
  59. $qry="UPDATE savedTemps 
  60.  
  61. SET htmlcss='$htmlcss', header='$header', nav='$nav.', titleWrap01='$titleWrap01', title='$title', titleWrap02='$titleWrap02', subheadWrap01='$subheadWrap01', subheading='$subheading', subheadWrap02='$subheadWrap02', flashWrap01='$flashWrap01', flashWrap02='$flashWrap02', flash01='$flash01', flashVar='$flashVar', flash02='$flash02', flashWrap03='$flashWrap03', descriptionWrap01='$descriptionWrap01', description='$description',  descriptionWrap02='$descriptionWrap02', generalWrap01='$generalWrap01', general='$general',  generalWrap02='$generalWrap02', aboutWrap01='$aboutWrap01', about='$about',  aboutWrap02='$aboutWrap02', paymentWrap01='$paymentWrap01',  payment01='$payment01', payment02='$payment02', paymentWrap02='$paymentWrap02', termsWrap01='$termsWrap01', terms='$terms',  termsWrap02='$termsWrap02', footer='$footer'";
  62.  
  63. $res=mysql_query($qry) or die("Error in query:".mysql_error());
  64.  
  65. }
  66. else
  67. {
  68. //  EXECUTE QUERY ---> 
  69. $query="INSERT savedTemps (
  70.  
  71.             tempID, 
  72.             htmlcss, 
  73.             header, 
  74.             nav, 
  75.             titleWrap01, 
  76.             title,
  77.             titleWrap02,
  78.             subheadWrap01, 
  79.             subheading,
  80.             subheadWrap02, 
  81.             flashWrap01,     
  82.             flashWrap02, 
  83.             flash01, 
  84.             flashVar,
  85.             flash02, 
  86.             flashWrap03,
  87.             descriptionWrap01,
  88.             description, 
  89.             descriptionWrap02,
  90.             generalWrap01, 
  91.             general, 
  92.             generalWrap02, 
  93.             aboutWrap01,
  94.             about, 
  95.             aboutWrap02,
  96.             paymentWrap01, 
  97.             payment01, 
  98.             payment02, 
  99.             paymentWrap02,
  100.             termsWrap01, 
  101.             terms, 
  102.             termsWrap02,
  103.             footer)
  104.  
  105.         VALUES(    
  106.             '$tempID', 
  107.             '$htmlcss', 
  108.             '$header', 
  109.             '$nav.', 
  110.             '$titleWrap01', 
  111.             '$title',
  112.             '$titleWrap02',
  113.             '$subheadWrap01', 
  114.             '$subheading',
  115.             '$subheadWrap02', 
  116.             '$flashWrap01',     
  117.             '$flashWrap02', 
  118.             '$flash01', 
  119.             '$flashVar', 
  120.             '$flash02', 
  121.             '$flashWrap03',
  122.             '$descriptionWrap01',
  123.             '$description', 
  124.             '$descriptionWrap02',
  125.             '$generalWrap01', 
  126.             '$general', 
  127.             '$generalWrap02', 
  128.             '$aboutWrap01',
  129.             '$about', 
  130.             '$aboutWrap02',
  131.             '$paymentWrap01', 
  132.             '$payment01', 
  133.             '$payment02', 
  134.             '$paymentWrap02',
  135.             '$termsWrap01', 
  136.             '$terms', 
  137.             '$termsWrap02',
  138.             '$footer')";
  139.             $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  140. }
  141.  
  142. //  CLOSE CONNECTION ---> 
  143. mysql_close($connection); 
  144.  
  145. //
  146.  
  147. ?>
  148. <script language="JavaScript">
  149. <!--
  150. window.location="<? print $returnURL?>";
  151. //-->
  152. </SCRIPT>
  153.  
Mar 28 '09 #1
1 6710
Atli
5,058 Expert 4TB
Hi.

An "undefined index" warning means that you tried to get an array element that does not exist.

Simply look through your code and find the array element the warning specified.
Make sure the spelling is correct and that the element is properly initialized.

If you are getting the elements from an outside source (HTML forms, XML, etc...), make sure that the array element actually does exists before you use it.
The isset function is great for that.

Also.
Using the short-tag syntax (<? ... ?>) to open a PHP block is a very very bad habit. They are disabled by default, so you are practically asking for future compatibility issues when using them.

It's always best to use <?php ... ?>. They always work, on all PHP servers.
Apr 8 '09 #2

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

Similar topics

12
by: Xeon | last post by:
Hi, Is there anyway to set a custom error handler which is actually a method of a class? i.e. setting the method eh() of class foo as error handler in the snippet below. class foo { function...
2
by: Wm | last post by:
I'm having a very hard time trying to add an edited listing to mySQL. I'm breaking this in to two halves, so that each error/problem can be pinpointed. The edit form queries mySQL and fills in...
2
by: NotGiven | last post by:
I have display error ON and error reporting to E_ALL. I have a form that opens fine. When you submit it, all the fields that have nothing in them, for example an un-selected radio button, throw...
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: 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...
2
by: tridirk | last post by:
Hi; I am getting a Objceted Expected Error on my forum site. I can't find what is wrong? Line: Char: Error: Object expected Code:0 the site is My SMF Forum
19
by: obtrs | last post by:
I have some code for drop down its not working it gives the errors every thing looks fine to me help me out. Errors Notice: Undefined index: from in C:\wamp\www\site\booking.php on line 6 ...
4
rahulephp
by: rahulephp | last post by:
i think i am missing something in the below script: It shows error an do not upload files to destination: Let me know how to solve this: <?php if (isset($_POST)) { $uploadArray=...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.