Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : PHP samples or help?Search Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC v6 Forum

 New Topic 
 
 Post Reply 
[1]  
 PHP samples or help? 
 Author   Message 
  Mark 
  
 Group: Members 
 Posts: 8 
 Joined: 2007-01-04 
 Profile
 Posted : 2007-01-08 11:52:56
I have a PHP app that needs to connect to QB using teh QODBC that I have installed on the clients machine.

I now need to run the PHP sample code to try to see if the whole thing works, but I cannot find any sample PHP code to run some sp_report queries.

I have the following code so far:

$constr = "Driver={QODBC Driver for QuickBooks};";
$constr = $constr."DFQ=C:\Path to QBCOMPANYFILE\FILE.QBW;";
$constr = $constr."OpenMode=M;OLE DB Services=-2;";

print "\nconnecting...";
if (!$conn = new COM("ADODB.Connection"))
    print "Unable to create an ADODB connection";

$conn->Open("CHDGP");

$today = date("Y-m-d");

$tmpStr =  "sp_report TxnDetailByAccount show Text, Blank, Date, RefNumber, Name, Memo, Debit, Credit, RunningBalance parameters DateFrom = {d'2004-04-01'}, DateTo = {d'".$today."'}, AccountFilterListIDs = '2C0001-1094780702' ";

$res = $conn->query($tmpStr);


But I am getting the error:

PHP Fatal error:  Uncaught exception 'com_exception' with message '
Source: ADODB.Connection
Description: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.' in G:\Website\test.php:43
Stack trace:
#0 G:\Website\test.php(43): com->query('sp_report TxnDe...')
#1 {main}
  thrown in G:\Website\test.php on line 43

What is going on?
Thanks! 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-01-08 15:05:20
Try looking at our sample: DisplaySQL.PHP  

  Top 
  Shanewaj 
  
 Group: Members 
 Posts: 22 
 Joined: 2007-09-24 
 Profile
 Posted : 2007-10-05 10:10:32

 sample: DisplaySQL.PHP  Does not work badly writen PHP code Here is the corrected version of DisplaySQL.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>QODBC PHP Script To Display SQL Results</title>
</head>
<body topmargin="3" leftmargin="3" marginheight="0" marginwidth="0" bgcolor="#ffffff" link="#000066" vlink="#000000" alink="#0000ff" text="#000000">

 <table >
    <tr>
        <td>
            <table border="2" bordercolor="black" bgcolor="white" cellpadding="5" cellspacing="0">
                <thead>
                    <caption align="top">QODBC PHP Script To Display SQL Results</caption>
                    <tr>
                        <th>Row</th>
       <?php
       set_time_limit(120);
       
       #Connect to a System DSN "QuickBooks Data" with no user or password
       $oConnect = odbc_connect("QuickBooks Data", "", "");
       
       #Set the SQL Statement
       $sSQL = "SELECT TOP 50 ListID, FullName, CompanyName FROM Customer";
       
       #Perform the query
       $oResult = odbc_exec($oConnect, $sSQL);
       $lFldCnt = 0;
       $lFieldCount = odbc_num_fields($oResult);
       while ($lFldCnt < $lFieldCount)
       {
        $lFldCnt++;
        $sFieldName = odbc_field_name($oResult, $lFldCnt);
        echo '<th> ' . $sFieldName  . ' </th>';
       }
       echo '
                    </tr>
                </thead>
                <tbody>
     ';
     $lRecCnt = 0;
     #Fetch the data from the database
     while(odbc_fetch_row($oResult)) {
      $lRecCnt++;
      echo'                    <tr>';
      echo' <td> ' .$lRecCnt. ' </td> ';
      $lFldCnt = 0;
      $lFieldCount = odbc_num_fields($oResult);
      while ($lFldCnt < $lFieldCount) {
       $lFldCnt++;
       $sFieldValue = trim(odbc_result($oResult, $lFldCnt));
       If ($sFieldValue == "") {
        echo '<td> </td>';
       }
       else {
        echo ' <td valign=\"Top\"> '. $sFieldValue. ' </td>';
       }
      }
      echo ' </tr>';
     }
     #Close the connection
     odbc_close($oConnect);
     echo '
                </tbody>
                <tfoot>
      <caption align=\"bottom\">Results of: '.$sSQL.'</caption>
     
                </tfoot> ';
    ?>
            </table>
        </td>
    </tr>
</table>
</body>
</html>

 

 
Md Shanewaj Rahman
Software Developer
Nulab Professional Imaging Pty. Ltd. 
 
  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to