Page 1 of 1

mssql_query problem

PostPosted: 11. January 2005 16:41
by zygwi
Config. Win2000/MS SQL SERVER
XAMPP 1.4.11 with PHP 5.0.3

mssql_query return FALSE when update or insert order.

Is there a solution ?

Thanks

PostPosted: 11. January 2005 17:54
by taustin
What exact query are you using?

PostPosted: 12. January 2005 09:52
by zygwi
this very simple example does not work :

$res=mssql_query("update MyTable set column1=value1 where column2=value2");

then "$res" is FALSE.

PostPosted: 12. January 2005 11:26
by Wiedmann
1)
$res=mssql_query("update MyTable set column1=value1 where column2=value2");

The columns "column1" and "column2" are varchar (--> no numbers in your query). So, the words "value1" and "value2" must be in ':
$res=mssql_query("update MyTable set column1='value1' where column2='value2'");

2)
But, the best is to look what MySQL tell you --> mysql_error()
(read the examples at php.net)

PostPosted: 12. January 2005 13:04
by zygwi
In fact, the true query is :
$res=mssql_query("update MyTable set column1='value1' where column2='value2'");
The problem is, the UPDATE is done, but mssql_query returns FALSE and mssql_error() returns 0 ( zero ).

It seems to be a bug of the new version of PHP ( 5.0.3).

PostPosted: 12. January 2005 13:32
by Wiedmann
Ups, sorry, my fault...

You wrote about the "Microsoft SQL Server Functions" and i about the "MySQL Functions". :oops:

In fact, the function mssql_error() didn't exist... you get no error message? (and mysql_error must be 0, because there was no query before)

With mssql you should use mssql_get_last_message() and mssql_rows_affected() instead after querys.


It seems to be a bug of the new version of PHP ( 5.0.3).

http://bugs.php.net/bug.php?id=31219

PostPosted: 12. January 2005 16:26
by zygwi
Thank you for your answer.

to get the error number, I wrote this generic function :

function mssql_error() {
$res = mssql_query("select @@ERROR", $this->Base->IDBase);
$this->ERROR = mssql_result($res,0,0);
return $this->ERROR;
}