Jump to content

UPDATE throws weird error


Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.