End of file

Hi,I;ve gotten all tangled up here and could use some help. I remember seeing newer code for this. Below are my code
and below the code are messages:


<?php
require "includes/getnumbers.php";
$host = "localhost";
//Database user name.
$login = "root";
//Database Password.
$dbpass = "";
//Database name.
$dbname = "homedb";
$PDO = new PDO("mysql:host=localhost;dbname=$dbname", "$login", "$dbpass");
?>


```html
&lt;!DOCT.....&lt;body&gt;

<?php if(isset($_GET['acctno'])) { $acctno = trim($_GET['acctno']); $R = "R"; try { $sql = "SELECT acctno,pd,payrec,orderno, bname,bstreet,bcity,bstate,bzip, sname,sstreet,scity,sstate,szip, terms,duedate FROM oocust WHERE acctno = :acctno AND payrec = :R AND pd = ''"; $query = $PDO->prepare($sql); $query->bindParam(":acctno", $acctno); $query->bindParam(":R", $R); $query->execute(); while($row = $query->fetch(PDO::FETCH_ASSOC)) { $acctno = $row['acctno']; $pd = $row['pd']; $payrec = $row['payrec']; $orderno = $row['orderno']; $bname = $row['bname']; $bstreet = $row['bstreet']; $bcity = $row['bcity']; $bstate = $row['bstate']; $bzip = $row['bzip']; $sname = $row['sname']; $sstreet = $row['sstreet']; $scity = $row['scity']; $sstate = $row['sstate']; $szip = $row['szip']; $terms = $row['terms']; $duedate = $row['duedate']; // the below code is for the date $format = "D M d Y g:ia"; $date = date($format, time()); // the above code is for the date $tax = $payable * $taxrate; $amtdue = $payable + $tax + $shipamt; $currdate = date('Y-m-d'); $date1 = $duedate; $date2 = $currdate; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); // echo "Difference is $months months, $days days."; $dayslate = $months *30; $dayslate = $dayslate + $days; $query = " INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,bemail, phone,contact,sname,sstreet,scity,sstate,szip,semail,terms,fob,shipdate,shipamt, dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno, amtdue,prevbal,balance) VALUES ('$acctno',$status','$pd','$payrec',$orderno','$bname','$bstreet','$bcity', '$bstate','$bzip','$bemail','$phone','$contact','$sname','$sstreet','$sscity','$sstate', '$szip','$semail','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp', '$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate', '$checkno,'$amtdue','$prevbal,','$balance')"; } } } ?>


```html
</B></BODY></HTML>

" }
}
}
?> " gives

: Parse error: syntax error, unexpected ‘}’, expecting catch (T_CATCH) in
C:\xampp\htdocs\invoice\invoiceinsert.php on line 258


" }
}
?> " gives:

Parse error: syntax error, unexpected '?> ', expecting catch (T_CATCH) in
C:\xampp\htdocs\invoice\invoiceinsert.php on line 259

First thing I notice is ,$orderno’ should be ,‘$orderno’

You created a try block but failed to create its’ catch block. Once you add the catch ($e) {} it should clear up.

Thanks for the input, I’m trying to learn the PDO approach.
Am I getting close?

Parse error: syntax error, unexpected ‘catch’ (T_CATCH) in C:\xampp\htdocs\invoice\invoiceinsert.php on line 145

<?php
require "includes/getnumbers.php"; 
if(isset($_GET['acctno']))
    { 
        $sql = "SELECT  
        acctno,pd,payrec,orderno, 
        bname,bstreet,bcity,bstate,bzip, 
        sname,sstreet,scity,sstate,szip, 
        terms,duedate 
        FROM oocust  WHERE payrec = 'R' && pd = ''"; 
         
        while($row = $query->fetch(PDO::FETCH_ASSOC))
    { 
            $acctno = $row['acctno']; 
            $pd = $row['pd']; 
            $payrec = $row['payrec']; 
            $orderno = $row['orderno'];  
            $bname = $row['bname']; 
            $bstreet = $row['bstreet']; 
            $bcity = $row['bcity']; 
            $bstate = $row['bstate']; 
            $bzip = $row['bzip']; 
            $sname = $row['sname']; 
            $sstreet = $row['sstreet']; 
            $scity = $row['scity']; 
            $sstate = $row['sstate']; 
            $szip = $row['szip']; 
            $terms = $row['terms']; 
            $duedate = $row['duedate']; 

            // the below code is for the date 
            $format = "D M d Y g:ia"; 
            $date = date($format, time()); 
            // the above code is for the date 

        $tax = $payable * $taxrate;
        $amtdue = $payable + $tax + $shipamt; 
	$currdate = date('Y-m-d');
	$date1 = $duedate;
	$date2 = $currdate;
	$diff = abs(strtotime($date2) - strtotime($date1));
	$years = floor($diff / (365*60*60*24));
	$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
	$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
// echo "Difference is $months months, $days days.";
$dayslate = $months *30;
$dayslate = $dayslate + $days;
$query = "
INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,bemail,
phone,contact,sname,sstreet,scity,sstate,szip,semail,terms,fob,shipdate,shipamt,
dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno,
amtdue,prevbal,balance)
VALUES ('$acctno',$status','$pd','$payrec','$orderno','$bname','$bstreet','$bcity',
'$bstate','$bzip','$bemail','$phone','$contact','$sname','$sstreet','$sscity','$sstate',
'$szip','$semail','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp',
'$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate',
'$checkno,'$amtdue','$prevbal,','$balance')";
        }  
         }catch (PDOException $e){ 
        echo "Database error: ".$e->getMessage(); 
    } 

?> 
</form></center></body></html>





Parse error: syntax error, unexpected 'catch' (T_CATCH) in C:\\xampp\\htdocs\\invoice\\invoiceinsert.php on line 145
 <?php
require "includes/getnumbers.php"; 
if(isset($_GET['acctno']))
    { 
        $sql = "SELECT  
        acctno,pd,payrec,orderno, 
        bname,bstreet,bcity,bstate,bzip, 
        sname,sstreet,scity,sstate,szip, 
        terms,duedate 
        FROM oocust  WHERE payrec = 'R' && pd = ''"; 
         
        while($row = $query->fetch(PDO::FETCH_ASSOC))
    { 
            $acctno = $row['acctno']; 
            $pd = $row['pd']; 
            $payrec = $row['payrec']; 
            $orderno = $row['orderno'];  
            $bname = $row['bname']; 
            $bstreet = $row['bstreet']; 
            $bcity = $row['bcity']; 
            $bstate = $row['bstate']; 
            $bzip = $row['bzip']; 
            $sname = $row['sname']; 
            $sstreet = $row['sstreet']; 
            $scity = $row['scity']; 
            $sstate = $row['sstate']; 
            $szip = $row['szip']; 
            $terms = $row['terms']; 
            $duedate = $row['duedate']; 

            // the below code is for the date 
            $format = "D M d Y g:ia"; 
            $date = date($format, time()); 
            // the above code is for the date 

        $tax = $payable * $taxrate;
        $amtdue = $payable + $tax + $shipamt; 
	$currdate = date('Y-m-d');
	$date1 = $duedate;
	$date2 = $currdate;
	$diff = abs(strtotime($date2) - strtotime($date1));
	$years = floor($diff / (365*60*60*24));
	$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
	$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
// echo "Difference is $months months, $days days.";
$dayslate = $months *30;
$dayslate = $dayslate + $days;
$query = "
INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,bemail,
phone,contact,sname,sstreet,scity,sstate,szip,semail,terms,fob,shipdate,shipamt,
dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno,
amtdue,prevbal,balance)
VALUES ('$acctno',$status','$pd','$payrec','$orderno','$bname','$bstreet','$bcity',
'$bstate','$bzip','$bemail','$phone','$contact','$sname','$sstreet','$sscity','$sstate',
'$szip','$semail','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp',
'$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate',
'$checkno,'$amtdue','$prevbal,','$balance')";
        }  
         }catch (PDOException $e){ 
        echo "Database error: ".$e->getMessage(); 
    } 

?> 
</form></center></body></html>

You added the catch, but eliminated the try. You need both, or none.

Yes literally missing the “try” on the try - catch.

<?php
require "includes/getnumbers.php";
if(isset($_GET['acctno']))
    try{
        $sql = "SELECT
        acctno,pd,payrec,orderno,
        bname,bstreet,bcity,bstate,bzip,
        sname,sstreet,scity,sstate,szip,
        terms,duedate
        FROM oocust  WHERE payrec = 'R' && pd = ''";

        while($row = $query->fetch(PDO::FETCH_ASSOC))
    {
            $acctno = $row['acctno'];
            $pd = $row['pd'];
            $payrec = $row['payrec'];
            $orderno = $row['orderno'];
            $bname = $row['bname'];
            $bstreet = $row['bstreet'];
            $bcity = $row['bcity'];
            $bstate = $row['bstate'];
            $bzip = $row['bzip'];
            $sname = $row['sname'];
            $sstreet = $row['sstreet'];
            $scity = $row['scity'];
            $sstate = $row['sstate'];
            $szip = $row['szip'];
            $terms = $row['terms'];
            $duedate = $row['duedate'];

            // the below code is for the date
            $format = "D M d Y g:ia";
            $date = date($format, time());
            // the above code is for the date

        $tax = $payable * $taxrate;
        $amtdue = $payable + $tax + $shipamt;
	$currdate = date('Y-m-d');
	$date1 = $duedate;
	$date2 = $currdate;
	$diff = abs(strtotime($date2) - strtotime($date1));
	$years = floor($diff / (365*60*60*24));
	$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
	$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
// echo "Difference is $months months, $days days.";
$dayslate = $months *30;
$dayslate = $dayslate + $days;
$query = "
INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,bemail,
phone,contact,sname,sstreet,scity,sstate,szip,semail,terms,fob,shipdate,shipamt,
dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno,
amtdue,prevbal,balance)
VALUES ('$acctno',$status','$pd','$payrec','$orderno','$bname','$bstreet','$bcity',
'$bstate','$bzip','$bemail','$phone','$contact','$sname','$sstreet','$sscity','$sstate',
'$szip','$semail','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp',
'$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate',
'$checkno,'$amtdue','$prevbal,','$balance')";
        }
         }catch (PDOException $e){
        echo "Database error: ".$e->getMessage();
    }

?>

crapola, I sent u my backup doc. here’s what I’ve come up with.


<?php
include ('getnumbers.php');
    if(isset($_GET['acctno']))
    $acctno = trim($_Get['acctno']);
 $R = "R";

      try
    {
        $sql = "SELECT
        acctno,pd,payrec,orderno,
        bname,bstreet,bcity,bstate,bzip,
        sname,sstreet,scity,sstate,szip,
        terms,duedate
        FROM oocust  WHERE payrec = 'R' && pd = ''";

        while($row = $query->fetch(PDO::FETCH_ASSOC))
    {
            $acctno = $row['acctno'];
            $pd = $row['pd'];
            $payrec = $row['payrec'];
            $orderno = $row['orderno'];
            $bname = $row['bname'];
            $bstreet = $row['bstreet'];
            $bcity = $row['bcity'];
            $bstate = $row['bstate'];
            $bzip = $row['bzip'];
            $sname = $row['sname'];
            $sstreet = $row['sstreet'];
            $scity = $row['scity'];
            $sstate = $row['sstate'];
            $szip = $row['szip'];
            $terms = $row['terms'];
            $duedate = $row['duedate'];

            // the below code is for the date
            $format = "D M d Y g:ia";
            $date = date($format, time());
            // the above code is for the date

        $tax = $payable * $taxrate;
        $amtdue = $payable + $tax + $shipamt;
	$currdate = date('Y-m-d');
	$date1 = $duedate;
	$date2 = $currdate;
	$diff = abs(strtotime($date2) - strtotime($date1));
	$years = floor($diff / (365*60*60*24));
	$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
	$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
// echo "Difference is $months months, $days days.";
$dayslate = $months *30;
$dayslate = $dayslate + $days;
$query = "
INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,bemail,
phone,contact,sname,sstreet,scity,sstate,szip,semail,terms,fob,shipdate,shipamt,
dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno,
amtdue,prevbal,balance)
VALUES ('$acctno',$status','$pd','$payrec','$orderno','$bname','$bstreet','$bcity',
'$bstate','$bzip','$bemail','$phone','$contact','$sname','$sstreet','$sscity','$sstate',
'$szip','$semail','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp',
'$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate',
'$checkno,'$amtdue','$prevbal,','$balance')";
        }
         }catch (PDOException $e){
        echo "Database error: ".$e->getMessage();
    }

?>
</form></center></body></html>


So is it working now, or do you still have a problem you need to work through?

Looks like you’re missing the closing bracket for the WHILE loop.
EDIT: See it now.

You’re missing prepare and execute for both queries.

<?php
require "includes/getnumbers.php";
if(isset($_GET['acctno']))
    try{
        $sql = "SELECT
        acctno,pd,payrec,orderno,
        bname,bstreet,bcity,bstate,bzip,
        sname,sstreet,scity,sstate,szip,
        terms,duedate
        FROM oocust  WHERE payrec = 'R' && pd = ''";
        $query = $PDO->prepare($sql);
		$query->execute();
        while($row = $query->fetch(PDO::FETCH_ASSOC))
    {
            $acctno = $row['acctno'];
            $pd = $row['pd'];
            $payrec = $row['payrec'];
            $orderno = $row['orderno'];
            $bname = $row['bname'];
            $bstreet = $row['bstreet'];
            $bcity = $row['bcity'];
            $bstate = $row['bstate'];
            $bzip = $row['bzip'];
            $sname = $row['sname'];
            $sstreet = $row['sstreet'];
            $scity = $row['scity'];
            $sstate = $row['sstate'];
            $szip = $row['szip'];
            $terms = $row['terms'];
            $duedate = $row['duedate'];

            // the below code is for the date
            $format = "D M d Y g:ia";
            $date = date($format, time());
            // the above code is for the date

        $tax = $payable * $taxrate;
        $amtdue = $payable + $tax + $shipamt;
	$currdate = date('Y-m-d');
	$date1 = $duedate;
	$date2 = $currdate;
	$diff = abs(strtotime($date2) - strtotime($date1));
	$years = floor($diff / (365*60*60*24));
	$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
	$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
// echo "Difference is $months months, $days days.";
$dayslate = $months *30;
$dayslate = $dayslate + $days;
$sql2 = "
INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,bemail,
phone,contact,sname,sstreet,scity,sstate,szip,semail,terms,fob,shipdate,shipamt,
dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno,
amtdue,prevbal,balance)
VALUES ('$acctno',$status','$pd','$payrec','$orderno','$bname','$bstreet','$bcity',
'$bstate','$bzip','$bemail','$phone','$contact','$sname','$sstreet','$sscity','$sstate',
'$szip','$semail','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp',
'$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate',
'$checkno,'$amtdue','$prevbal,','$balance')";
$query2 = $PDO->prepare($sql2);
$query2->execute();
        }
         }catch (PDOException $e){
        echo "Database error: ".$e->getMessage();
    }

?>

Hi, I’m getting the below message and don’t know the resolution.
The offending line has ‘//’ comment.

Parse error: syntax error, unexpected ‘;’ in C:\xampp\htdocs\invoice\invoiceinsert.php

<?php 
$host = "localhost";  
//Database user name.     
$login = "root"; 
//Database Password. 
$dbpass = ""; 
//Database name. 
$dbname = "homedb"; 
$PDO = new PDO("mysql:host=localhost;dbname=$dbname", "$login", "$dbpass"); 
?>

<?php 
require "includes/getnumbers.php"; 
if(isset($_GET['acctno'])) 
    try
   {  
        $sql = "SELECT 
acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,
phone,contact,sname,sstreet,scity,sstate,szip,terms,fob,shipdate,
shipamt,dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,
datepaid,dayslate,checkno,amtdue,prevbal,balance 
        FROM oocust  WHERE payrec = 'R' && pd = ''";  
        $query = $PDO->prepare($sql); 
		$query->execute(); 
        while($row = $query->fetch(PDO::FETCH_ASSOC)) 
    {  
$acctno=$_POST['acctno'];
$status=$_POST['status'];
$pd=$_POST['pd'];
$payrec=$_POST['payrec'];
$orderno=$_POST['orderno'];
$bname=$_POST['bname'];
$bstreet=$_POST['bstreet'];
$bcity=$_POST['bcity'];
$bstate=$_POST['bstate'];
$bzip=$_POST['bzip'];
$bemail=$_POST['bemail'];
$phone=$_POST['phone'];
$contact=$_POST['contact'];
$sname=$_POST['sname'];
$sstreet=$_POST['sstreet'];
$scity=$_POST['scity'];
$sstate=$_POST['sstate'];
$szip=$_POST['szip'];
$semail=$_POST['semail'];
$terms=$_POST['terms'];
$fob=$_POST['fob'];
$shipdate=$_POST['shipdate'];
$shipamt=$_POST['shipamt']; 
$dateord=$_POST['dateord'];
$datecomp=$_POST['datecomp'];
$duedate=$_POST['duedate'];
$qty=$POST['qty'];
$descr=$_POST['descr'];
$payable=$_POST['payable'];
$tax=$_POST['tax'];
$paidamt=$_POST['paidamt'];
$datepaid=$_POST['datepaid'];
$dayslate=$_POST['dayslate'];
$checkno=$_POST['checkno'];
$amtdue=$_POST['amtdue'];
$prevbal=$_POST['prevbal'];
$balance=$_POST['balance']; 
	$currdate = date('Y-m-d'); 
	$date1 = $duedate; 
	$date2 = $currdate; 
	$diff = abs(strtotime($date2) - strtotime($date1)); 
	$years = floor($diff / (365*60*60*24)); 
	$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); 
	$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*
// echo "Difference is $months months, $days days 
$dayslate = $months *30; // ?
$dayslate = $dayslate + $days;  // ?
$sql2 = " 
INSERT INTO oocust (acctno,status,pd,payrec,orderno,bname,bstreet,bcity,bstate,bzip,
phone,contact,sname,sstreet,scity,sstate,szip,terms,fob,shipdate,shipamt,
dateord,datecomp,duedate,qty,descr,payable,tax,paidamt,datepaid,dayslate,checkno, 
amtdue,prevbal,balance)
VALUES ('$acctno',$status','$pd','$payrec','$orderno','$bname','$bstreet','$bcity', 
'$bstate','$bzip','$phone','$contact','$sname','$sstreet','$sscity','$sstate', 
'$szip','$terms','$fob','$shipdate','$shipamt','$dateord','$datecomp', 
'$duedate','$qty','$descr','$payable','$tax','$paidamt','$datepaid','$dayslate', 
'$checkno,'$amtdue','$prevbal,','$balance')"; 
$query2 = $PDO->prepare($sql2); 
$query2->execute(); 
  }  
   } 
catch (PDOException $e)
   {  
        echo "Database error: ".$e->getMessage();  
    }  
?>

Looks like you’ve got some unfinished math and open line here.

$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*

Thanks

hi guys, take a break from the tough stuff.
I could use some help here. I don’t understand this one. Below is the ‘fetch_taxrate’
code.

<?php
$taxrate=$_POST['search_term'];
$stat = mysql_connect('localhost','root','');
$stat = mysql_select_db('homedb');
$query = "SELECT taxrate FROM numbers Where taxrate='$taxrate'";
$stat = @mysql_fetch_assoc(mysql_query($query));
echo $stat["taxrate"];
?> 

Below is the ‘numbers’ sql

id receiptno orderno taxrate bank

1 154 150 0.575 999.99

Here is the message:

Warning: require(includes/fetch_taxrate.php): failed to open stream:
No such file or directory in C:\xampp\htdocs\invoice\invoiceinsert.php on line 101

Fatal error: require(): Failed opening required ‘includes/fetch_taxrate.php’
(include_path=‘.;C:\xampp\php\PEAR’) in C:\xampp\htdocs\invoice\invoiceinsert.php
on line 101

Thought you had made the switch to PDO. What’s up with this old mysql. BTW don’t suppress errors with @

Can I assume this code is from invoiceinsert.php? That’s the page indicated by the error.
You might need to change it to LIKE. It could be that table field is int and you are posting a string. Maybe field is 6.00 but you are posting 6.0 or 6
By changing to LIKE should account for much of this.

<?php
$taxrate=$_POST['search_term'];
mysql_connect('localhost','BnBDemo','MainDemo321');
mysql_select_db('test');
$query = "SELECT taxrate FROM numbers WHERE taxrate LIKE '$taxrate%'";
$stat = mysql_fetch_assoc(mysql_query($query));
echo $stat["taxrate"];
?>

Drummin, the code is the include ‘fetch_taxrate’ and you’re right, I haven’t yet
changed it to pdo. ‘taxrate’ is decimal.