#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    188
    Rep Power
    93

    Syntax Error - PervasiveSQL - SQL state 37000 in SQLExecDirect


    First off, I know this isn't the right forum but it looks more "correct" than any others.

    We have a proprietary billing system that uses PervasiveSQL to connect. I'm trying to use ODBC to connect an intranet site for us. It's been done in the past but on a machine with ColdFusion on it and I can't get ColdFusion to run on this XP box so I'm porting everything to PHP but don't know much about ODBC & PHP/SQL nor Pervasive's Flavor of SQL...

    So, for what it's worth, here's my problem:

    PHP Code:
            echo "Search Data: ".$searchdata." and Search Value: ".$searchvalue;
            
    $conn dbConnect('query');
    //        $select = "SELECT cust_id, bill_to, add1, add2, city, state, zip, bill_phone_1, bill_fax FROM QCust WHERE ".$searchdata." LIKE ".$searchvalue;
            
    $select "SELECT cust_id, bill_to, add1, add2, city, state, zip, bill_phone_1, bill_fax FROM QCust WHERE 'bill_to' LIKE 'PRINT'";
            if (!
    $result odbc_exec($conn$select)) {echo "There was a problem connecting to the database.";} 
    As it is the script seems to run. When I uncomment the third line and comment out the forth I'm using data from a form instead of the hard coded variables. I then get the following error on screen:

    "Warning: odbc_exec() [function.odbc-exec]: SQL error: [Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Syntax Error: SELECT cust_id, bill_to, add1, add2, city, state, zip, bill_phone_1, bill_fax FROM QCust WHERE cust_id LIKE aaaaa<< ??? >>a, SQL state 37000 in SQLExecDirect in C:\xampp\htdocs\BCT\intranet\cs\customers\index.php on line 50
    There was a problem connecting to the database."

    The << ??? >> is always in the LIKE section directly in front of the last character I type in.

    And, I get the "There was a problem connecting to the database." message. When I use the hard coded line I do not get that message.

    I'm preg_replacing non-alphanumeric characters in the form data so there's nothing funny in the variables supplied to the SQL statement.

    I googled SQL State 37000 but didn't come up with anything I thought was relevant.

    I'm sure it's a simple problem due to my ignorance of what Pervasive is expecting but I'll be damned if I know what.

    And we can't get any help from our Pervasive vendor 'cause we are three versions behind.

    Any thoughts on what to try?

    Thanks,

    Mike
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Location
    Glendale AZ
    Posts
    188
    Rep Power
    93
    PHP Code:
    $select "SELECT cust_id, bill_to, add1, add2, city, state, zip, bill_phone_1, bill_fax FROM QCust WHERE '$searchdata' LIKE '$searchvalue'"
    Needed ' around the variables.

    Don't know if that solves the problem but it gets rid of the error. Now to see if I can actually get data out of the database...

IMN logo majestic logo threadwatch logo seochat tools logo