473,839 Members | 1,519 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. }
  24.  
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[]'];
  5.  
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. }
  25.  
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 3030
Dormilich
8,658 Recognized Expert Moderator Expert
if $ProjName is a string, you should enclose it in single quotation marks.

regards
Oct 9 '08 #2
micky125
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
Markus
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
micky125
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); 
  4.  
  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.  
  11. var b=y.insertCell(1); 
  12. var xx= document.createElement('input'); 
  13. xx.type="text"; 
  14. xx.name="Staff[]"; 
  15. b.appendChild(xx);
  16.  
  17. var c=y.insertCell(2); 
  18. var xx= document.createElement('input'); 
  19. xx.type="text"; 
  20. xx.name="Wage[]"; 
  21. c.appendChild(xx);
  22.  
  23. var d=y.insertCell(3); 
  24. var xx= document.createElement('input'); 
  25. xx.type="text"; 
  26. xx.name="Hours[]"; 
  27.  
  28.  

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[]']; 
  5.  
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
Markus
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
  1.  
  2. $Date = $_POST['date']
  3.  
  4.  
Oct 9 '08 #6
pbmods
5,821 Recognized Expert Expert
Heya, Micky.

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

http://php.net/variables.external
Oct 10 '08 #7
micky125
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.

THANKS.
Oct 10 '08 #8
micky125
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
pbmods
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.

http://blog.pbmods.com/2007/11/27/wh...lopers-part-1/
Oct 10 '08 #10

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

Similar topics

9
2369
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 up and used the code
2
3916
by: GBartgo | last post by:
Is there someone who knows how to generate a gaussian mixture in c++?
59
7061
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;
13
2116
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:
3
2639
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:
26
25625
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
4
1832
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 $object->functionX ? ... <?php $object->functionZ ? to include php code in html code.
24
9885
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 Apache 2.0.55 with PHP 4.4.4 on Windows XP Pro. I have read everything I can find, and have...
8
3081
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.
15
5286
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.
0
9855
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
9697
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
10906
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...
1
7828
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...
0
7017
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3132
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.