SitePoint Sponsor

User Tag List

Results 1 to 16 of 16

Thread: end of file

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Code:
    <?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]<!DOCT.....<body>
    [/HTML]
    <?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($formattime()); 
                
    // 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 Code:
    </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

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    First thing I notice is ,$orderno' should be ,'$orderno'

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,123
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You created a try block but failed to create its' catch block. Once you add the catch ($e) {} it should clear up.

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    Code:
    <?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>

  5. #5
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    You added the catch, but eliminated the try. You need both, or none.

  6. #6
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Yes literally missing the "try" on the try - catch.

    PHP Code:
    <?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($formattime()); 
                
    // 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(); 
        } 

    ?>

  7. #7
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    crapola, I sent u my backup doc. here's what I've come up with.
    Code:
    <?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>
    Last edited by ckdoublenecks; Feb 26, 2014 at 12:07. Reason: clarity

  8. #8
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,123
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    So is it working now, or do you still have a problem you need to work through?

  9. #9
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Looks like you're missing the closing bracket for the WHILE loop.
    EDIT: See it now.

  10. #10
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You're missing prepare and execute for both queries.

    PHP Code:
    <?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($formattime()); 
                
    // 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(); 
        } 

    ?>

  11. #11
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    Code:
    <?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();  
        }  
    ?>

  12. #12
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Looks like you've got some unfinished math and open line here.
    PHP Code:
    $days floor(($diff $years 365*60*60*24 $months*30*60*60*24)/ (60

  13. #13
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

  14. #14
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    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

  15. #15
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    725
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    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 Code:
    <?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"];
    ?>

  16. #16
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Drummin, the code is the include 'fetch_taxrate' and you're right, I haven't yet
    changed it to pdo. 'taxrate' is decimal.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •