Jump to content

mssql_query select syntax error after WHERE


KlaasV

Recommended Posts

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?

 

Link to comment
Share on other sites

  • 2 weeks later...

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.