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 -
function addActual()
-
{
-
var myTab = document.getElementById('myTable2');
-
var row=myTab.rows.length; var y=myTab.insertRow(row);
-
var a=y.insertCell(0);
-
var xx= document.createElement('input');
-
xx.type="text";
-
xx.name="Date[]";
-
a.appendChild(xx);
-
var b=y.insertCell(1);
-
var xx= document.createElement('input');
-
xx.type="text";
-
xx.name="Staff[]";
-
b.appendChild(xx);
-
var c=y.insertCell(2);
-
var xx= document.createElement('input');
-
xx.type="text";
-
xx.name="Wage[]";
-
c.appendChild(xx); var d=y.insertCell(3);
-
var xx= document.createElement('input');
-
xx.type="text";
-
xx.name="Hours[]";
-
}
-
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 -
$Date = $_POST['Date[]'];
-
$Staff = $_POST['Staff[]'];
-
$Wage = $_POST['Wage[]'];
-
$Hours = $_POST['Hours[]'];
-
I also think this is stopping my mysql select statement as i use -
function getProjectDetails()
-
{
-
global $ProjName;
-
$temp = mysql_query("SELECT Float, Extension, Excusable, NonExcusable, Delays, Value, LiquidatedDamages, totalLiquidatedDamages
-
FROM ProjectDetails
-
WHERE Name= $ProjName")or die('<hr />MySQL Error1: ' .mysql_error(). '<hr />');
-
$row = mysql_fetch_array($temp);
-
return $row;
-
}
-
// A function to allow overall project variables to be manipulated.
-
function makeVariableProjectDetails()
-
{
-
global $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable,
-
$projectDelays, $projectValue, $liquidateddamages, $totalliquidateddamages;
-
$temp = getProjectDetails();
-
$projectFloat = $temp['ProjectFloat'];
-
$projectExtension = $temp['Extension'];
-
$projectExcusable = $temp['Excusable'];
-
$projectNonExcusable = $temp['NonExcusable'];
-
$projectDelays = $temp['Delays'];
-
$projectValue = $temp['Value'];
-
$liquidateddamages = $temp['LiquidatedDamages'];
-
$totalliquidateddamages = $temp['totalLiquidatedDamages'];
-
}
-
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
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?
pbmods 5,821
Recognized Expert Expert
This code: -
foreach( $array as $index => $element )
-
{
-
.
-
.
-
.
-
}
-
is roughly equivalent to this: -
for( $index = 0; $index <= count($array); $index++ )
-
{
-
$element = $array[$index];
-
-
.
-
.
-
.
-
}
-
Except that foreach runs through EVERY element in the array, even if it has a non-numeric index. http://php.net/foreach
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
Hi guys ive been trying to use these foreach loops and was just looking clarification to find whetehr i am doing it rite. -
//Email Variables
-
$EmailFro = $_POST['EmailFrom'];
-
$EmailT = $_POST['EmailTo'];
-
$EmailDat = $_POST['EmailDate'];
-
$EmailSubjec = $_POST['EmailSubject'];
-
$EmailMessag = $_POST['EmailMessage'];
-
-
foreach ($EmailFro as $i => $temp) {
-
$EmailFrom[$i] = $temp;
-
}
-
foreach ($EmailT as $i => $temp) {
-
$EmailTo[$i] = $temp;
-
}
-
foreach ($EmailDat as $i => $temp) {
-
$EmailDate[$i] = $temp;
-
}
-
foreach ($EmailSubjec as $i => $temp) {
-
$EmailSubject[$i] = $temp;
-
}
-
foreach ($EmailMessag as $i => $temp) {
-
$EmailMessage[$i] = $temp;
-
}
-
-
// With the remaining foreach loops being
-
-
foreach ($Dat as $i => $temp) {
-
$Date[$i] = $temp;
-
}
-
foreach ($Staf as $i => $temp) {
-
$Staff[$i] = $temp;
-
}
-
foreach ($Wag as $i => $temp) {
-
$Wage[$i] = $temp;
-
}
-
foreach ($Hour as $i => $temp) {
-
$Hours[$i] = $temp;
-
}
-
foreach ($SubDat as $i => $temp) {
-
$SubDate[$i] = $temp;
-
}
-
foreach ($Sub as $i => $temp) {
-
$Subs[$i] = $temp;
-
}
-
foreach ($Pric as $i => $temp) {
-
$Price[$i] = $temp;
-
}
-
foreach ($Typ as $i => $temp) {
-
$Type[$i] = $temp;
-
}
-
-
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 -
// A function to allow overall project variables to be manipulated.
-
function makeVariableProjectDetails()
-
{
-
global $ProjName, $projectFloat, $projectExtension, $projectExcusable, $projectNonExcusable,
-
$projectDelays, $projectValue, $liquidateddamages, $totalliquidateddamages;
-
-
$temp = mysql_query("SELECT Name, ProjectFloat, Extension, Excusable, NonExcusable, Delays, Value, LiquidatedDamages, totalLiquidatedDamages
-
FROM ProjectDetails
-
WHERE Name= '$ProjName'")or die('<hr />MySQL Error1: ' .mysql_error(). '<hr />');
-
$temp = mysql_fetch_array($temp);
-
$projectFloat = $temp['ProjectFloat'];
-
$projectExtension = $temp['Extension'];
-
$projectExcusable = $temp['Excusable'];
-
$projectNonExcusable = $temp['NonExcusable'];
-
$projectDelays = $temp['Delays'];
-
$projectValue = $temp['Value'];
-
$liquidateddamages = $temp['LiquidatedDamages'];
-
$totalliquidateddamages = $temp['totalLiquidatedDamages'];
-
}
-
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?
pbmods 5,821
Recognized Expert Expert
Save your server some CPU cycles and just do: -
$EmailFrom = $_POST['EmailFrom'];
-
$EmailTo = $_POST['EmailTo'];
-
$EmailDate = $_POST['EmailDate'];
-
$EmailSubject = $_POST['EmailSubject'];
-
$EmailMessage = $_POST['EmailMessage'];
-
Its result is identical to that of the code that you posted.
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 up and used the code
|
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
$object->functionX ? ... <?php $object->functionZ ? to include
php code in html code.
|
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...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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,...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |