Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql UPDATE statement failing with SQL error

Tags:

sql

php

ms-access

Keep getting this warning:

Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression '' WHERE id = 86'., SQL state 37000 in SQLExecDirect

no matter how I edit this SQL UPDATE command:

$sqlU = "UPDATE inv20152016
        SET coNo = '$coNo', cusNo = '$cusNo', rcvTech = '$rcvTech', 
            rcvLoc = '$rcvLoc', rcvDate = '$rcvDate', rcyTech = '$rcyTech', 
            rcyLoc = '$rcyLoc', rcyDate = '$rcyDate', rtnTech = '$rtnTech', 
            rtnLoc = '$rtnLoc', rtnDate = '$rtnDate', cusInvNo = '$cusInvNo', 
            notes = '$notes
        WHERE id = '$rcyId'";
    if (!$rs=odbc_exec($conn,$sqlU)) {
        echo '<br />Error UPDATE\'ing new record: (' . $sqlU . ')<br />';
        goto end;
    } else {
        echo '<br />RECORD successfully UPDATE\'d in database.recycle20152016<br />'; //$sqlUpdate<br />;
        header('location: searchDb.php');
        exit();
    }

After trying to submit UPDATE I get the following returned on the submit page:

Error UPDATE'ing new record: (UPDATE inv20152016 SET coNo = '658454', cusNo = '3282', rcvTech = 'Dave Phillips', rcvLoc = 'Sparington', rcvDate = '2016-11-15', rcyTech = 'Melo Hazak', rcyLoc = 'Wildmere', rcyDate = '2016-02-16', rtnTech = 'Dave Phillips', rtnLoc = 'Sparington', rtnDate = '2016-02-25', cusInvNo = '', notes = ' WHERE id = 86)

It appears as though all the UPDATE vars are as expected, including the id in the WHERE clause. I have played with the quoting and spacing between vars without change. I have verified the data types in the ACCESS backend match the data being pushed for update.

Any ideas why this UPDATE statement might not be working?

like image 202
commnux Avatar asked Sep 15 '26 08:09

commnux


1 Answers

You left a single quote ' off the notes = '$notes columnId var.

Try:

$sqlU = "UPDATE inv20152016
        SET coNo = '$coNo', cusNo = '$cusNo', rcvTech = '$rcvTech', rcvLoc = '$rcvLoc', rcvDate = '$rcvDate', rcyTech = '$rcyTech', rcyLoc = '$rcyLoc', rcyDate = '$rcyDate', rtnTech = '$rtnTech', rtnLoc = '$rtnLoc', rtnDate = '$rtnDate', cusInvNo = '$cusInvNo', notes = '$notes'
        WHERE id = '$rcyId'";
    if (!$rs=odbc_exec($conn,$sqlU)) {
        echo '<br />Error UPDATE\'ing new record: (' . $sqlU . ')<br />';
        goto end;
    } else {
        echo '<br />RECORD successfully UPDATE\'d in database.recycle20152016<br />'; //$sqlUpdate<br />;
        header('location: searchDb.php');
        exit();
    }
like image 158
scriptz Avatar answered Sep 16 '26 21:09

scriptz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!