0

I've fought this for days - can someone help?

<?php
mysql_connect(localhost,root,"");
mysql_select_db(oob) or die( "Unable to select database"); 
$query = "
INSERT INTO oocust (payrec,invnum,date,time,name,name,street,state,zip,terms,fob,ordernum,dateord,datecomp,datepaid,charges,paidamt,tax,amtdue)
VALUES('$payrec','$invnum','$date','$time','$name','$street','$state','$zip','$terms','$fob','$ordernum','$dateord','$datepaid','$charges','$paidamt','$tax','$amtdue')";
echo "data inserted</font><br /><br />"; 
$stat = mysql_query($query) or die('Query failed: ' . mysql_error());  
if (isset( $_POST['payrec']) ) 
{
$payrec=$_POST['payrec'];  
$invnum=$_POST['invnum'];  
$date=$_POST['date'];  
$time=$_POST['time'];
$name=$_POST['name'];  
$street=$_POST['street'];  
$state=$_POST['state'];  
$zip=$_POST['zip'];  
$terms=$_POST['terms'];  
$fob=$_POST['fob'];
$ordernum=$_POST['ordernum'];
$dateord=$_POST['dateord'];
$datecomp=$_POST['datecomp'];  
$datepaid=$_POST['datepaid'];  
$charged=$_POST['charged'];  
$paidamt=$_POST['paidamt'];  
$tax=$_POST['tax'];
$amtdue=$_POST['amtdue'];
//  charges x tax(.06) + shipamt = amtdue
mysql_connect(localhost,root,""); 
mysql_select_db(numbersdb) or die( "Unable to select database"); 
if(!empty($_POST["submit"])) 
{ 
$invnum = $_POST['invnum']; 
} 
mysql_query("UPDATE numbdata SET invnum=invnum+1"); 
$result=mysql_query("select number from numbdata") or die ("Error - could not retrieve receipt number from database");
$data=mysql_fetch_assoc($result);
echo ".Invoice number ".$data['invnum'];
mysql_close();
?>
<HTML><HEAD>
<SCRIPT>
changed = 0;
function change(field)
{
for (var node = 0; node < field.attributes.length; node++)
{
if (field.attributes[node].nodeName == 'class')
{
if (field.defaultValue == field.value)
{
if (field.attributes[node].nodeValue != 'bgwhite')
{ 
field.attributes[node].nodeValue = 'bgwhite';
changed--;
} 
}
else
{
if (field.attributes[node].nodeValue != 'bgyellow')
{ 
field.attributes[node].nodeValue = 'bgyellow';
changed++;
} 
}
field.Form.reset.disabled = ! changed;
break;
}
}
}

function changeall(Form)
{
Form.reset.disabled = true;
changed = 0;
for (var el = 0; el < Form.elements.length; el++)
{
if (Form.elements[el].name != 'reset') /* Some way needed of knowing which to reset. */ 
{
for (var node = 0; node < Form.elements[el].attributes.length; node++)
{
if (Form.elements[el].attributes[node].nodeName == 'class')
{
Form.elements[el].attributes[node].nodeValue = 'bgwhite';
break; 
} 
}

}
}
} 
</SCRIPT>

<STYLE type=text/css>.highlight {
	BACKGROUND: #ff6699
}
.text {
	COLOR: #ffffff
}
.both {
	BACKGROUND: black; COLOR: white
}
</STYLE>

<STYLE>INPUT.bgyellow {
	BACKGROUND-COLOR: yellow
}
</STYLE>
<script type="text/javascript">
var today = new Date();
var date = today.getMonth() + " / " + today.getDate() + " / " + today.getFullYear();
</script>
<!--increment date to create due date-->
</head>
<body>
<script type="text/javascript">document.write(date);
</script>
<center>
<B><font size=+2>Work Order Input Form</font></b></center>
<P><FORM name="Form">
AR/AP: <SELECT name=payrec>
<OPTION class=highlight value=ar selected>R
<OPTION class=highlight value=ap>P
</OPTION></SELECT>

Order No: <INPUT TYPE="text" size=5 name="ordernum">
Invoice No: <INPUT TYPE="text" size=5 name="invnum" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.date.focus();">
Date: <INPUT TYPE="text" size=10 name="date" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.name.focus();"><p>

<b>Bill</b> - Name: <INPUT TYPE="text" name=bname>
Street: <INPUT TYPE="text" name=bstreet>
State: <SELECT name=bstate>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT>
Zip: <INPUT TYPE="text" name="bzip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.contact.focus();"><br>
<b>Contact: </b><INPUT TYPE="text" name=contact><BR>

<b>Ship</b> - Name: 
<INPUT TYPE="text" name=sname>
Street <INPUT TYPE="text" name=sstreet>
State <SELECT name=sstate>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT>
Zip: <INPUT TYPE="text" name="szip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.terms.focus();"><p>

Terms: <SELECT name=terms>
<OPTION class=highlight value=net 10 selected>Net 10
<OPTION class=highlight value=1_10_30ga>1 10 Net 30
<OPTION class=highlight value=2_10_30>2 10 Net 30
<OPTION class=highlight value=cash>Cash
</OPTION></SELECT>

FOB: <SELECT name=fob>
<OPTION class=highlight value=Destination selected>Destination
<OPTION class=highlight value=Origin>Origin
</OPTION></SELECT><p>

<b>Dates</b> - Ordered: 
<INPUT TYPE="text" size=10 name="dateord" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datecomp.focus();">
Completed: <INPUT TYPE="text" size=10 name="datecomp" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.duedate.focus();">
Due($): <INPUT TYPE="text" size=10 name="duedate" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.charges.focus();"><p>

Charges: <INPUT TYPE="text" name=charges>
Tax: <INPUT TYPE="text" name tax>
Shipping: <INPUT TYPE="text" name shipamt>
Amount Due: <INPUT TYPE="text" name=amtdue><p>

<INPUT type="submit" value="submit data" />
</p></form></body></html> 

<input type=text value="Old Orchard Plumbing"><br>
<input type=text value="2210 E. Hogan Hollow Road"><br>
<input type=text value="Margate, Fl  33063"><br>
<img src="dave pic.jpg">
<center>
<B><font size=+2>Work Order Input Form</font></b></center>

<P><FORM name="Form">
AR/AP = <SELECT name=payrec>
<OPTION class=highlight value=ar selected>R
<OPTION class=highlight value=ap>P
</OPTION></SELECT><BR>

<INPUT TYPE="text" size=5 name="ordernum">Order No<br>
<INPUT TYPE="text" size=5 name="invnum" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.date.focus();">Invoice No.<br />
<INPUT TYPE="text" size=10 name="date" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.name.focus();">Date<br />
<INPUT TYPE="text" name=name>Name<BR>
<INPUT TYPE="text" name=street>Street<BR>

state = <SELECT name=state>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT><BR>

<INPUT TYPE="text" size=5 name="zip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.contact.focus();">Zip Code<br />
<INPUT TYPE="text" name=contact>Contact<BR>

Terms = <SELECT name=terms>
<OPTION class=highlight value=net 10 selected>Net 10
<OPTION class=highlight value=1_10_30ga>1 10 Net 30
<OPTION class=highlight value=2_10_30>2 10 Net 30
<OPTION class=highlight value=cash>Cash
</OPTION></SELECT><BR>

FOB = <SELECT name=fob>
<OPTION class=highlight value=Destination selected>Destination
<OPTION class=highlight value=Origin>Origin
</OPTION></SELECT><BR>

<INPUT TYPE="text" size=10 name="dateord" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datecomp.focus();">Date Ordered<br />
<INPUT TYPE="text" size=10 name="datecomp" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datepaid.focus();">Date Completed<br />
<INPUT TYPE="text" size=10 name="datepaid" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.charges.focus();">Date Paid<br />
<INPUT TYPE="text" name=charges>Charges<BR>
<INPUT TYPE="text" name=paidamt>Amount Paid<BR>
<INPUT TYPE="text" name tax>tax<BR>
<INPUT type="submit" value="submit data">
</p></form></body></html>
3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by ckdoublenecks
0

this is the current code and the error: below is the printout showing the database fields and I get this message:

data inserted

Query failed: Column count doesn't match value count at row 1

<?php
mysql_connect(localhost,root,"");
mysql_select_db(oodb) or die( "Unable to select database"); 
$query = "
INSERT INTO oocust (payrec,invnum,date,time,name,name,street,state,zip,terms,fob,ordernum,dateord,datecomp,datepaid,charges,paidamt,tax,amtdue)
VALUES('$payrec','$invnum','$date','$time','$name','$street','$state','$zip','$terms','$fob','$ordernum','$dateord','$datepaid','$charges','$paidamt','$tax','$amtdue')";
echo "data inserted</font><br /><br />"; 
$stat = mysql_query($query) or die('Query failed: ' . mysql_error());  
if (isset( $_POST['payrec']) ) 
{
$pd=$_POST['pd'];
$payrec=$_POST['payrec'];
$ordernum=$_POST['ordernum'];
$invnum=$_POST['invnum'];  
$bname=$_POST['bname'];  
$bstreet=$_POST['bstreet'];  
$bstate=$_POST['bstate'];
$bcity=$_POST['bcity'];
$bzip=$_POST['bzip'];
$sname=$_POST['sname'];  
$sstreet=$_POST['sstreet'];  
$sstate=$_POST['sstate'];
$scity=$_POST['scity'];
$szip=$_POST['szip'];
$contact=$_POST['contact'];
$terms=$_POST['terms'];
$fob=$_POST['fob'];
$shipdate=$_POST['shipdate'];
$shipamt=$_POST['shipamt'];  
$dateord=$_POST['dateord'];
$datecomp=$_POST['datecomp'];
$duedate=$_POST['duedate'];  
$datepaid=$_POST['datepaid'];
$qty=$_POST['qty'];  
$desc=$_POST['desc'];  
$charges=$_POST['charges'];  
$paidamt=$_POST['paidamt'];
$dayslate=$_POST['dayslate'];  
$tax=$_POST['tax'];
$amtdue=$_POST['amtdue'];
$paidsum=$_POST['paidsum'];
}
mysql_connect(localhost,root,""); 
mysql_select_db(numbersdb) or die( "Unable to select database"); 
if(!empty($_POST["submit"])) 
{ 
$invnum = $_POST['invnum']; 
} 
mysql_query("UPDATE numbdata SET invnum=invnum+1"); 
$result=mysql_query("select number from numbdata") or die ("Error - could not retrieve receipt number from database");
$data=mysql_fetch_assoc($result);
echo ".Invoice number ".$data['invnum'];
mysql_close();
?>
<HTML><HEAD>
<SCRIPT>
changed = 0;
function change(field)
{
for (var node = 0; node < field.attributes.length; node++)
{
if (field.attributes[node].nodeName == 'class')
{
if (field.defaultValue == field.value)
{
if (field.attributes[node].nodeValue != 'bgwhite')
{ 
field.attributes[node].nodeValue = 'bgwhite';
changed--;
} 
}
else
{
if (field.attributes[node].nodeValue != 'bgyellow')
{ 
field.attributes[node].nodeValue = 'bgyellow';
changed++;
} 
}
field.Form.reset.disabled = ! changed;
break;
}
}
}

function changeall(Form)
{
Form.reset.disabled = true;
changed = 0;
for (var el = 0; el < Form.elements.length; el++)
{
if (Form.elements[el].name != 'reset') /* Some way needed of knowing which to reset. */ 
{
for (var node = 0; node < Form.elements[el].attributes.length; node++)
{
if (Form.elements[el].attributes[node].nodeName == 'class')
{
Form.elements[el].attributes[node].nodeValue = 'bgwhite';
break; 
} 
}

}
}
} 
</SCRIPT>

<STYLE type=text/css>.highlight {
	BACKGROUND: #ff6699
}
.text {
	COLOR: #ffffff
}
.both {
	BACKGROUND: black; COLOR: white
}
</STYLE>

<STYLE>INPUT.bgyellow {
	BACKGROUND-COLOR: yellow
}
</STYLE>
<script type="text/javascript">
var today = new Date();
var date = today.getMonth() + " / " + today.getDate() + " / " + today.getFullYear();
</script>
<!--increment date to create due date-->
</head>
<body>
<script type="text/javascript">document.write(date);
</script>
<center>
<B><font size=+2>Work Order Input Form</font></b></center>
<P><FORM name="Form">
Paid? If so - enter"P":<input type=text size=1 name=pd><p>

AR/AP: <SELECT name=payrec>
<OPTION class=highlight value=ar selected>R
<OPTION class=highlight value=ap>P
</OPTION></SELECT><br>

Order No: <INPUT TYPE="text" size=5 name="ordernum"><br>
Invoice No: <INPUT TYPE="text" size=5 name="invnum" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.bname.focus();"><p>

<b>Bill</b> - Name: <INPUT TYPE="text" name=bname>
Street: <INPUT TYPE="text" name=bstreet>
State: <SELECT name=bstate>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT>
City: <INPUT TYPE="text" name="bcity">

</OPTION></SELECT>
Zip: <INPUT TYPE="text" size=5name="bzip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.contact.focus();"><br>
<b>Contact: </b><INPUT TYPE="text" name=contact><BR>

<b>Ship</b> - Name: 
<INPUT TYPE="text" name=sname>
Street <INPUT TYPE="text" name=sstreet>

State <SELECT name=sstate>
<OPTION class=highlight value=fl selected>Florida
<OPTION class=highlight value=ga>Georgia
<OPTION class=highlight value=al>Alabama
<OPTION class=highlight value=la>Louisiana
<OPTION class=highlight value=sc>South Carolina
</OPTION></SELECT>
City: <INPUT TYPE="text" name="scity">

</OPTION></SELECT>
Zip: <INPUT TYPE="text" size=5name="szip" MAXLENGTH=5
onKeyUp="if(this.value.length==this.size)document.form.terms.focus();"><p>

Terms: <SELECT name=terms>
<OPTION class=highlight value=net 10 selected>Net 10
<OPTION class=highlight value=1_10_30ga>1 10 Net 30
<OPTION class=highlight value=2_10_30>2 10 Net 30
<OPTION class=highlight value=cash>Cash
</OPTION></SELECT>

FOB: <SELECT name=fob>
<OPTION class=highlight value=Destination selected>Destination
<OPTION class=highlight value=Origin>Origin
</OPTION></SELECT><p>

<b>Ship</b> - Amt:<INPUT TYPE="text" size=10 name="shipamt">
Date: <INPUT TYPE="text" size=7 name="shipamt" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.dateord.focus();"><br>
<b>Dates</b> - Ordered: 
<INPUT TYPE="text" size=10 name="dateord" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datecomp.focus();">
Completed: <INPUT TYPE="text" size=10 name="datecomp" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.duedate.focus();">
Due: <INPUT TYPE="text" size=10 name="duedate" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.datepaid.focus();">
Paid: <INPUT TYPE="text" size=10 name="datepaid" MAXLENGTH=10
onKeyUp="if(this.value.length==this.size)document.form.qty.focus();"><p>
Qty: <INPUT TYPE="text" size=5 name=qty>
Description: <INPUT TYPE="text" size=25 name=desc>
Charges: <INPUT TYPE="text" size=7 name=charges>
Paid Amt: <INPUT TYPE="text" size=7 name=paidamt>
Tax: <INPUT TYPE="text" size=6 name tax><p>
<b>Shipping</b> - Date: <INPUT TYPE="text" size=10 name shipdate>
Amt:<INPUT TYPE="text" size=7 name shipamt><p>
<b>Amount Due</b>: <INPUT TYPE="text" size=7 name=amtdue><p>

<INPUT type="submit" value="submit data" />
</p></form></body></html>

oocust
Field Type Null Default Comments MIME
id int(5) No
pd varchar(1) No
payrec varchar(1) No
ordernum int(5) No
invnum int(5) No
bname varchar(25) No
bstreet varchar(25) No
bstate varchar(15) No
bcity varchar(15) No
bzip int(5) No
sname varchar(25) No
sstreet varchar(25) No
sstate varchar(15) No
scity varchar(15) No
szip int(5) No
contact varchar(15) No
terms varchar(12) No
fob varchar(11) No
shipdate varchar(10) No
shipamt decimal(7,2) No
dateord varchar(10) No
datecomp varchar(10) No
duedate varchar(10) No
datepaid varchar(10) No
qty int(5) No
desc varchar(25) No
charges decimal(7,2) No
paidamt decimal(7,2) No
dayslate int(4) No
tax decimal(6,2) No
amtdue decimal(7,2) No
paidsum decimal(7,2) No

0

Thanks for your help. I was neglecting this section:

INSERT INTO oocust (pd,payrec,ordernum,invnum,bname,bstreet,bstate,bcity,bzip,sname,sstreet,sstate,scity,szip,contact,terms,fob,shipdate,shipamt,dateord,datecomp,duedate,datepaid,qty,desc,charges,paidamt,
dayslate,tax,amtdue,paidsum)
VALUES('$pd','$payrec','$ordernum','$invnum','$bname','$bstreet','$bstate','$bcity','$bzip','$sname','$sstreet','$sstate','$scity','$szip','$contact','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp','$duedate','$datepaid','$qty','$desc',
'$charges','$paidamt','$dayslate','$tax','$amtdue','$paidsum')";

I made the above corrections but still got the below message:

data inserted
Query failed: 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 'desc,charges,paidamt, dayslate,tax,amtdue,paidsum) VALUES('','','','','','',''' at line 1

I've spent the longest pouring over this and do not see the error in the above code ?

0

The variables that make up your VAULE part don't exits at this point in the script.
You create them later in the block

if (isset( $_POST['payrec']) )
      {
      $pd=$_POST['pd'];
      $payrec=$_POST['payrec'];
       ...
      }

so move this blok to the top of your script

Edited by pzuurveen: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.