473,574 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mixture between html and php- UNIDENTIFIED INDEX

36 New Member
Lo all,

Had me head wrecked the whole week with a really stupid problem that came down to me not reading something but now when im running the php file i have errors switched on and i have bout 15 unidentified index but the problem is that i have used the code
Expand|Select|Wrap|Line Numbers
  1. function addActual()
  2. {
  3. var myTab = document.getElementById('myTable2');
  4. var row=myTab.rows.length; var y=myTab.insertRow(row);
  5. var a=y.insertCell(0);
  6. var xx= document.createElement('input');
  7. xx.type="text";
  8. xx.name="Date[]";
  9. a.appendChild(xx);
  10. var b=y.insertCell(1);
  11. var xx= document.createElement('input');
  12. xx.type="text";
  13. xx.name="Staff[]";
  14. b.appendChild(xx);
  15. var c=y.insertCell(2);
  16. var xx= document.createElement('input');
  17. xx.type="text";
  18. xx.name="Wage[]";
  19. c.appendChild(xx); var d=y.insertCell(3);
  20. var xx= document.createElement('input');
  21. xx.type="text";
  22. xx.name="Hours[]";
  23. }
to add a row of a table in my input form but i have alot of them and as you can see they start array lists. the code in me php to call these is

Expand|Select|Wrap|Line Numbers
  1. $Date = $_POST['Date[]']; 
  2. $Staff = $_POST['Staff[]'];
  3. $Wage = $_POST['Wage[]'];
  4. $Hours = $_POST['Hours[]'];
I also think this is stopping my mysql select statement as i use

Expand|Select|Wrap|Line Numbers
  1. function getProjectDetails()
  2. {
  3.     global $ProjName;
  4.     $temp = mysql_query("SELECT   Float, Extension, Excusable, NonExcusable, Delays, Value, LiquidatedDamages, totalLiquidatedDamages 
  5.               FROM     ProjectDetails
  6.               WHERE    Name= $ProjName")or die('<hr />MySQL Error1: ' .mysql_error(). '<hr />'); 
  7.     $row = mysql_fetch_array($temp);
  8.     return $row;
  9. }
  10. // A function to allow overall project variables to be manipulated.
  11. function makeVariableProjectDetails()
  12. {
  13.     global $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable,
  14.         $projectDelays, $projectValue, $liquidateddamages, $totalliquidateddamages;
  15.     $temp = getProjectDetails();
  16.     $projectFloat = $temp['ProjectFloat'];
  17.     $projectExtension = $temp['Extension'];
  18.     $projectExcusable = $temp['Excusable'];
  19.     $projectNonExcusable = $temp['NonExcusable'];
  20.     $projectDelays = $temp['Delays'];
  21.     $projectValue = $temp['Value'];
  22.     $liquidateddamages = $temp['LiquidatedDamages'];
  23.     $totalliquidateddamages = $temp['totalLiquidatedDamages'];
  24. }
where the error message

MySQL Error1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Float, Extension, Excusable, NonExcusable, Delays, Value, Liquid

comes. So is this connected and any1 ideas... im bout 99% positive me sql query is sound and i had ProjName in input form added so it wasnt that?
Oct 9 '08 #1
14 3012
8,658 Recognized Expert Moderator Expert
if $ProjName is a string, you should enclose it in single quotation marks.

Oct 9 '08 #2
36 New Member
sound one that solved the mysql problem... still have to figure the
Undefined index: EmailFrom[] in /home/moneill/public_html/mainPHP.php on line 37

which are me arrays..
Oct 9 '08 #3
6,050 Recognized Expert Expert
sound one that solved the mysql problem... still have to figure the
Undefined index: EmailFrom[] in /home/moneill/public_html/mainPHP.php on line 37

which are me arrays..
Post the code concerning your arrays. I currently can't find them in your given code.
Oct 9 '08 #4
36 New Member
lo markus

just got in from work there the code im using in the html file is basically having

header 1 h2 h3 h4 h5 etc |BUTTON|

There is zero input boxes below this so when you first press button javascript kicks in with the code

Expand|Select|Wrap|Line Numbers
  1. function addActual() 
  2. var myTab = document.getElementById('myTable2'); 
  3. var row=myTab.rows.length; var y=myTab.insertRow(row); 
  5. var a=y.insertCell(0); 
  6. var xx= document.createElement('input'); 
  7. xx.type="text"; 
  8. xx.name="Date[]"; 
  9. a.appendChild(xx); 
  11. var b=y.insertCell(1); 
  12. var xx= document.createElement('input'); 
  13. xx.type="text"; 
  14. xx.name="Staff[]"; 
  15. b.appendChild(xx);
  17. var c=y.insertCell(2); 
  18. var xx= document.createElement('input'); 
  19. xx.type="text"; 
  20. xx.name="Wage[]"; 
  21. c.appendChild(xx);
  23. var d=y.insertCell(3); 
  24. var xx= document.createElement('input'); 
  25. xx.type="text"; 
  26. xx.name="Hours[]"; 

I have a couple of these all adding rows to different tables and it updates them ok. The problem i am having is that the inputs that it creates doesnt appear to work in the php program as i get the error;

unidentified index

I am using $_POST to pass them from html to php by

Expand|Select|Wrap|Line Numbers
  1. $Date = $_POST['Date[]'];  
  2. $Staff = $_POST['Staff[]']; 
  3. $Wage = $_POST['Wage[]']; 
  4. $Hours = $_POST['Hours[]']; 
It is only the variables that i pass to php using this format all the normal inputs are accepted but not these. The problem i am guessing it is is that the javascript is not being passed to php but i cant be sure ... have you any ideas on this.
Oct 9 '08 #5
6,050 Recognized Expert Expert
You're receive and undefined error, not unidentified.

When you pass an array to POST, you access it like an array.

Expand|Select|Wrap|Line Numbers
  2. $Date = $_POST['date']
Oct 9 '08 #6
5,821 Recognized Expert Expert
Heya, Micky.

When you name an input with '[]' at the end, it creates an array on the PHP side.

Oct 10 '08 #7
36 New Member
sound one guys in work now but having to work till 10pm gmt the night so uve helped me loads. its in for next friday an i cant work on it over the weekend.

Oct 10 '08 #8
36 New Member
lol hey guys well ive done what u say and fair enuf it works but how do i separate the array i get into smaller parts.
I have tried the usual
for($i=1; $i<=count("theA rray"); $i++) //"theArray" is generic

but this throws an undefined offset which is when the array part im accessing doesnt exist. I have also tried using

explode(",", "theArray")

but it throws array to string conversion...

because of this i get undefined offset within any for loop i use with these arrays.
Oct 10 '08 #9
5,821 Recognized Expert Expert
For greater efficiency, consider using foreach. Putting count() in the for loop is a bit inefficient, as the array elements are count()'ed with each iteration.

Oct 10 '08 #10

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

Similar topics

by: Dave Smithz | last post by:
Hi, Summary: Best way to divide out the HTML and PHP in some code I inherited. How can I keep the HTML files separate? Full Details: I've now been working two weeks on PHP / MySQL code I inherited and the client is a happy bunny. This was my first crash course outing with PHP, but with basic PERL experience found it fairly easy to pick...
by: GBartgo | last post by:
Is there someone who knows how to generate a gaussian mixture in c++?
by: Lennart Björk | last post by:
Hi All, I have a tiny program: <!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>MyTitle</title> <meta http-equiv="Content-Type" content="text/html;
by: Stephen Kay | last post by:
Is there a way to redirect every single page on an existing web site through a php function? In other words, say I have a whole functional HTML web site, never written to use any php. Now I would like to have a php function handle displaying every page, for example, instead of: http://www.mysite.com/mypage.html you would call:
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm running into some PHP behavior that I do not understand in PHP 5.1.2. I need to parse the HTML from the following carefully constructed URI:
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any idea? Thanks you very much
by: Ming | last post by:
Hi folks, I have a php file, it contains just a few php codes. The php codes I need to use is to construct an object, and use it several times, from html head until the last line of html code. I know I can construct the same object (I am using php5) several times, something like $object = new $class, and use several <?php...
by: Gary Hasler | last post by:
I want apache to parse all .html files for php code. Our 'real' web server is rented from ICDsoft ( php 5 on Apache on Linux whatever), and their instruction is to add the following to the .htaccess file: AddHandler application/x-httpd-php .html ....which works great. However, our local in-office server for testing and viewing our sites is...
by: jumperbl | last post by:
Hi, I am a noob and I was wondering if there is way to generate random mixture of alphabets and numbers? For example: 1234567890ABCDEFG or 4BA92ABD293BC3890 the length needs to be 17 characters long.
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
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...
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...
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...
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...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.