ober Posted August 24, 2009 Share Posted August 24, 2009 My update statement looks like this: $query = "UPDATE DTCONTRACT SET sponsor_addr = '".$_REQUEST['addr']."' WHERE CONTRACT_ID = '".$_REQUEST['exist_study']."'"; This is only for testing so don't get me on security. I can take the resulting output of that query and run it directly in Enterprise Manager and it works great. When I run this same query via the PHP page, it says: UPDATE DTCONTRACT SET sponsor_addr = 'test test fd' WHERE CONTRACT_ID = 'ADD06053' Incorrect syntax near the keyword 'and'. THERE IS NO 'AND' IN THE GD QUERY. I can insert into and update other tables in the database but this one is giving me a problem. I assumed a permission problem but I don't think it would let me update other tables if that was the case. Can anyone think of a reason why it would throw that error? Quote Link to comment https://forums.phpfreaks.com/topic/171686-update-throws-weird-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2009 Share Posted August 24, 2009 Are you 100% sure the error is coming from that query? Edit: perhaps mssql_get_last_message() contains an error from an earlier query in the code. Best guess is that your page is getting requested twice by the browser (assuming you are using FF and one of the conditions that causes it to request a page twice is present) and on the second request the $_REQUEST variables are empty and one of the queries on your page is giving a syntax error. Otherwise, could be a mssql/php client bug. Quote Link to comment https://forums.phpfreaks.com/topic/171686-update-throws-weird-error/#findComment-905329 Share on other sites More sharing options...
ober Posted August 25, 2009 Author Share Posted August 25, 2009 100% sure. If I change the query to cause a different error, it throws that error. It isn't requesting it twice (I am using FF however) but I know the variables are not empty.... and regardless, there is no 'and' in the query to begin with. I think there is a permissions problem with that table. I attempted to add the field to a different table and I can update that one just fine. Now I'm wondering if there is a "repair" type function for MSSQL. Quote Link to comment https://forums.phpfreaks.com/topic/171686-update-throws-weird-error/#findComment-905762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.