473,587 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Undefined index error for the last element of array

1 New Member
Undefined index for the last element of array while fetching datas from db through an array variable. I use for each loop to seperate and also in_array()...ki ndly help pls.....


Here is the code......
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4. include("includes/global_inc.php");
  5.  
  6. $qry1=$_REQUEST['qry'];
  7. $feilds2=$_REQUEST['fields1'];
  8. $cnt=$_REQUEST['count'];
  9. $feild_name=explode(",",$feilds2);
  10. $iquery=mysql_query("$qry1")
  11.     or die(mysql_error());
  12.  
  13. echo "<table border='1'>";
  14. echo "<tr>";
  15. for($i=0;$i<$cnt;$i++)
  16. {
  17. echo "<th>".$feild_name[$i]."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>";
  18.  
  19. }
  20.  
  21. echo "</tr>";
  22.  
  23. for($g=0;$g<$cnt;$g++)
  24. {
  25. while($test=mysql_fetch_array($iquery))
  26.     {
  27.         echo "<tr align='center'>";
  28.  
  29.  
  30.  
  31.             echo"<td><font color='black'>".$test[$feild_name[$g]]."</font></td>";
  32.  
  33.  
  34.  
  35.  
  36.         echo"</tr>";
  37.     }
  38.  
  39. }
  40.  
  41. echo "</table>";
  42. ?>
  43.  
  44.  
  45.  
  46.  
Feb 16 '12 #1
1 1680
YarrOfDoom
1,247 Recognized Expert Top Contributor
Are you sure $cnt has the correct information? Why don't you calculate it yourself?
Feb 16 '12 #2

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

Similar topics

11
498
by: Chris | last post by:
I have a simple search feature that searches 3 fields in 3 separate tables in a MySQL db, and I'm getting an 'undefined index' error, but only in the first section (first table)of the results. The undefined index is tied to the docs.projID in the "if ($row_search == 1)". This if statement is there to control to format of the link as pages...
1
1773
by: shalini11 | last post by:
Hello, I am using a page that has a dropdown list. when the user selects an item from the list and click on submit button, it opens a new page and displays the selected item. I've used as method in my form. and request to retrieve the selected value: <form method="POST" name="frmcriteria" action="test.php" target="_blank" onsubmit="return...
6
20844
by: jsgoodrich | last post by:
I am looking for some help if anyone can lend a hand. I have a simple php website that displays a table from my mysql database. To prep for my MCSE I moved my home server to Windows 2003 Standard, I installed mysql and php 5 to run some of my databases and websites. Under Linux the site worked fine, under windows I keep getting Notice...
3
2056
by: JJM0926 | last post by:
I've got a contact form with a submit button where users have to enter their support information. Some fields are required some are not. When I test out the form if I leave everything blank I get these two undefined index error : Notice: Undefined index: CurrentCustomer in E:\WebSites\mysite\www \contactus.php on line 9 Notice:...
7
1389
by: ridgedale | last post by:
I wonder if anyone can help resolve an issue I've come across in making a customer's website live when it has tested fine in my own hosting space. I am getting the following errors: Notice: Undefined index: vartalk For reference I provide the following links: My hosting space (where everything appears to be working fine):...
7
2525
by: Philth | last post by:
Hey there, it has to be said that I am a complete novice in PHP, I know this is a common error and has probably been covered to some degree already - but my head really does hurt - so I couldn't stand trawling through anymore forums hunting for the right answer. Anyway - here goes. The page I'm having trouble with is a simple edit row type...
1
1620
by: jason1987 | last post by:
I keep getting the undefined index error on the bottom two rows of my code simparent and equtype - the other two work fine yet there is no difference in my code. equtypeid is even from the same table as the top two $equid=$HTTP_POST_VARS; $fromuserid=$HTTP_POST_VARS; $simparent=$HTTP_POST_VARS; $equtype=$HTTP_POST_VARS; these are...
6
1630
by: nadomt | last post by:
Happy friday to all! I am getting the below error when visiting my user filter page. i have gone to line 68, but cant see what the problem is...can anyone assist? advanced THANK YOU! Error: E_NOTICE URL: http://mysite.com/admin/users_filter.php File: /home1/mysite/public_html/admin/users_filter.php Line: 68
3
3319
by: furqi | last post by:
hi i am actually having problem in this code i am trying to check the value in the if condition in the very last lines of the code but i am facing an error of "undefined index" can anybody tell me so that i can solve my problem. <html> <body> <form method="GET" action="switchcases.php"> <input type='text' name='furqan' > <?php...
3
2023
by: mediator | last post by:
Hello I have a php contact email form on my a ecommerce shop website ! I am getting a Undefined index error messages coming from the top of the php code, the email form its self works fine, HERE IS THE ERROR MESSAGES Notice: Undefined index: Name in E:\domains\t\tools2diy.co.uk\user\htdocs\contact.php on line 13 Notice: Undefined...
0
7849
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...
0
8215
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. ...
0
8347
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...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5718
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...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1189
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...

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.