474,040 Members | 2,401 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
14 3050
micky125
36 New Member
LOL PBMods u hit the nail on the head there... im only outa uni (doing this for dissertation in construction management [yes a major change]) and all i learned was java, cobol, mysql and prolog so what ur saying is 100% but i have looked at foreach code and have not understood it. In ur explanation it is very clear tbh but what is $element, is this the $i or do i go for column headings?
Oct 10 '08 #11
pbmods
5,821 Recognized Expert Expert
This code:
Expand|Select|Wrap|Line Numbers
  1. foreach( $array as $index => $element )
  2. {
  3.   .
  4.   .
  5.   .
  6. }
  7.  
is roughly equivalent to this:

Expand|Select|Wrap|Line Numbers
  1. for( $index = 0; $index <= count($array); $index++ )
  2. {
  3.   $element = $array[$index];
  4.  
  5.   .
  6.   .
  7.   .
  8. }
  9.  
Except that foreach runs through EVERY element in the array, even if it has a non-numeric index.

http://php.net/foreach
Oct 10 '08 #12
micky125
36 New Member
U learn something new every day... thanks for explaining it to me cus i know uve got the blog and probs explain everyday of the week but sound1. Ill pass this teaching on LOL. :D
Oct 10 '08 #13
micky125
36 New Member
Hi guys ive been trying to use these foreach loops and was just looking clarification to find whetehr i am doing it rite.
Expand|Select|Wrap|Line Numbers
  1. //Email Variables
  2. $EmailFro = $_POST['EmailFrom'];
  3. $EmailT = $_POST['EmailTo'];
  4. $EmailDat = $_POST['EmailDate'];
  5. $EmailSubjec = $_POST['EmailSubject'];
  6. $EmailMessag = $_POST['EmailMessage'];
  7.  
  8. foreach ($EmailFro as $i => $temp) {
  9.   $EmailFrom[$i] = $temp;
  10. }
  11. foreach ($EmailT as $i => $temp) {
  12.   $EmailTo[$i] = $temp;
  13. foreach ($EmailDat as $i => $temp) {
  14.   $EmailDate[$i] = $temp;
  15. }
  16. foreach ($EmailSubjec as $i => $temp) {
  17.   $EmailSubject[$i] = $temp;
  18. }
  19. foreach ($EmailMessag as $i => $temp) {
  20.   $EmailMessage[$i] = $temp;
  21. }
  22.  
  23. // With the remaining foreach loops being
  24.  
  25. foreach ($Dat as $i => $temp) {
  26.   $Date[$i] = $temp;
  27. }
  28. foreach ($Staf as $i => $temp) {
  29.   $Staff[$i] = $temp;
  30. }
  31. foreach ($Wag as $i => $temp) {
  32.   $Wage[$i] = $temp;
  33. }
  34. foreach ($Hour as $i => $temp) {
  35.   $Hours[$i] = $temp;
  36. }
  37. foreach ($SubDat as $i => $temp) {
  38.   $SubDate[$i] = $temp;
  39. }
  40. foreach ($Sub as $i => $temp) {
  41.   $Subs[$i] = $temp;
  42. }
  43. foreach ($Pric as $i => $temp) {
  44.   $Price[$i] = $temp;
  45. }
  46. foreach ($Typ as $i => $temp) {
  47.   $Type[$i] = $temp;
  48. }
  49.  
  50.  
I get errors of

Warning: Invalid argument supplied for foreach() in /home/moneill/public_html/mainPHP.php on line 231

Notice: Undefined offset: 1 in /home/moneill/public_html/mainPHP.php on line 238

and the period of coding that this represents is

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

The reason why I want to call a variable by for loop is that the 800 lines of code have a lot of for loops and the program, as well as 20000 words has to be in for wednesddday morning so im a bit caught for time. Any one any ideas of the problem?
Oct 13 '08 #14
pbmods
5,821 Recognized Expert Expert
Save your server some CPU cycles and just do:
Expand|Select|Wrap|Line Numbers
  1. $EmailFrom = $_POST['EmailFrom'];
  2. $EmailTo = $_POST['EmailTo'];
  3. $EmailDate = $_POST['EmailDate'];
  4. $EmailSubject = $_POST['EmailSubject'];
  5. $EmailMessage = $_POST['EmailMessage'];
  6.  
Its result is identical to that of the code that you posted.
Oct 16 '08 #15

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

Similar topics

9
2391
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
3921
by: GBartgo | last post by:
Is there someone who knows how to generate a gaussian mixture in c++?
59
7130
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
2136
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
2649
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
25654
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
1840
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
9919
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
3117
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
5301
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
10535
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
12129
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
11996
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7860
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
6646
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
6817
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5402
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
2
4935
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3956
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.