KlaasV Posted June 29, 2010 Share Posted June 29, 2010 Dear freaks We have a MSSQLserver, a CentOS with Apache 2.2.3 + PHP 5.1.6, and a Debian Lenny with Apache 2.2.9 + PHP 5.2.6.-1. I use mssql_query to select some records from a MSSQLtable. On the CentOS machine every page works perfect. I copied the php-pages to the Debian machine, and most work, but not the ones with a 'SELECT' with a WHERE clause. clientnr is a varchar(5) ...WHERE clientnr = '$number'; # returns 'syntax error' ...WHERE clientnr = '$number%'; # no syntax error, but no records returned although there should be ...WHERE clientnr = '25486'; # returns 'syntax error' ...WHERE clientnr = '25486%'; # no syntax error, but no records returned although there should be I tried converting and casting, but the result is always: with '%' no records found, without '%' syntax error. activated is a boolean ...WHERE activated = 0; # returns a blank page ...WHERE activated = 1; # returns the correct selection ...WHERE activated = -1; # returns the correct selection (nothing) ...WHERE activated <> 7; # returns the correct selection (all records) ...WHERE activated <> 0; # returns the correct selection (all 1) ...WHERE activated <> 1; # returns a blank page What is wrong on my Debian? Quote Link to comment https://forums.phpfreaks.com/topic/206169-mssql_query-select-syntax-error-after-where/ Share on other sites More sharing options...
david_g17 Posted July 12, 2010 Share Posted July 12, 2010 weird. I'd look at the encoding settings in FreeTDS and make sure they match on the two Linux machines. Quote Link to comment https://forums.phpfreaks.com/topic/206169-mssql_query-select-syntax-error-after-where/#findComment-1084915 Share on other sites More sharing options...
KlaasV Posted July 16, 2010 Author Share Posted July 16, 2010 thanks David. I can't find any encoding settings; in freetds.conf was no directive for it, not on the working machine, nor on the failing one. I tried to add 'client charset = UTF-8' but that doesn't change anything. When I submit the query with tsql, it works perfect, both via -S and -H (from the freetds user guide I understand one way is bypassing freetds, the other uses freetds.conf). I too presume it is an encoding problem, especially since I found that comparing to different numbers gives different results (being one of the forementioned: either a blank page or a syntax error notification). Any other file I need to examine? or another way of PHP sending queries without mssql? Quote Link to comment https://forums.phpfreaks.com/topic/206169-mssql_query-select-syntax-error-after-where/#findComment-1086992 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.