[freetds] SELECT querys fine, but INSERT query packets get malformed?

Scott Kovach scott at webdropstudio.com
Fri Jan 30 10:02:24 EST 2009

Thanks in advance to anyone that might help with this.

We are interacting remotely with a sql server 2k DB from a unix machine. 
We are using the mssql libraries in PHP as our programming environment 
on the unix machine.

Here is our test script:

$link = mssql_pconnect (MSDBHOST . ":" . MSDBPORT, MSDBUSER, MSDBPASS);
if(!$link || !mssql_select_db(MSDB, $link))
    die('Unable to connect or select database!');
$query_select = "SELECT * FROM VA_ORDHDR WHERE VA_ORDER_NUMBER = '1409-1'";
$queryid = mssql_query ($query_select, $link);

$query_insert = "INSERT INTO VA_ORDHDR 
$queryid = mssql_query ($query_insert, $link);

$queryid = mssql_query ($query_select, $link);

We CAN connect, send queries, and get results from querys from the 
remote sql server just fine.  However, all of the "INSERT" or "UPDATE" 
queries fail, and the response is "Incorrect syntax near the keyword 
'and'." (note:  there is no 'and' in the query) The DBA of the remote 
sql server is saying that they fail due to some problem with the packets 

"Error: 17832, Severity: 20, State: 7
Connection opened but invalid login packet(s) sent.  Connection closed.

You should have a talk with your provider. It seems that the packets
coming from your service are not valid."

I dont see how the sql server response of Incorrect syntax near the keyword 'and'." can be caused by the packets sent, since the connection is fine and a
response packet is received back from them and the select querys are sent in valid packets.  I've attached a log of a
single connection with 3 queries.  If anyone can tell me if the failed inserts/updates are a freetds/php issue or whether its an issue on the remote sql server, i would be forever grateful. 

-- Scott

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/applefile
Size: 1487 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20090130/ed18f7ca/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetds_log.log
Type: application/octet-stream
Size: 58234 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20090130/ed18f7ca/attachment.obj 

More information about the FreeTDS mailing list