mssql_query problem

Problems with the Windows version of XAMPP, questions, comments, and anything related.

mssql_query problem

Postby zygwi » 11. January 2005 16:41

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
zygwi
 
Posts: 30
Joined: 11. January 2005 16:16
Location: FRANCE

Postby taustin » 11. January 2005 17:54

What exact query are you using?
taustin
 
Posts: 150
Joined: 24. September 2004 00:23
Location: Huntington Beach CA

Postby zygwi » 12. January 2005 09:52

this very simple example does not work :

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

then "$res" is FALSE.
zygwi
 
Posts: 30
Joined: 11. January 2005 16:16
Location: FRANCE

Postby Wiedmann » 12. January 2005 11:26

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)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby zygwi » 12. January 2005 13:04

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).
zygwi
 
Posts: 30
Joined: 11. January 2005 16:16
Location: FRANCE

Postby Wiedmann » 12. January 2005 13:32

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
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby zygwi » 12. January 2005 16:26

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;
}
zygwi
 
Posts: 30
Joined: 11. January 2005 16:16
Location: FRANCE


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 151 guests