July 22, 2009 at 11:04 am
Hi all,
We have an apache/php based web server connecting to MS SQL 2005 server to access the DB.
There's an error on the site which points to the mssql query.
Below are the error messages. Do you see anything wrong?
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'ORDER'. (severity 15) in /var/www/db/query.php on line 201
Warning: mssql_query() [function.mssql-query]: General SQL Server error: Check messages from the SQL Server (severity 15) in /var/www/db/query.php on line 201
Warning: mssql_query() [function.mssql-query]: Query failed in /var/www/db/query.php on line 401
Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in /var/www/db/query.php on line 204
These are the actual lines
$SQLQuery=$SQLQuery." WHERE pagenum=".$num; = line 199
$SQLQuery=$SQLQuery." ORDER BY pagenum DESC"; = line 200
$result= mssql_query($SQLQuery, $link_id); = line 201
= line 202
= line 203
if (mssql_num_rows($result)==0) = line 204
July 22, 2009 at 12:27 pm
I really have no idea about PHP. It looks like you are creating the query on the fly with dynamic SQL directly on the page... Does PHP give you the option of outputting what the actual query would be when you're done with it? Can you output the query and post it here?
For example I can write the following in TSQL to output the text of my dynamic SQL query
Declare @sql varchar(50)
set @sql = 'Select mycolumn'
set @sql = @sql + 'From mytable'
set @sql = @sql + 'Where mycolumn = 123'
print @sql
I'm imagining it doesn't like whatever is contained in the num variable... but that's just a guess, if you give us the whole query it would be helpful. Another possibility would be to take a server trace and see what is actually being executed against your server.
Hope that helps at least a little.
-Luke.
July 22, 2009 at 2:38 pm
Thanks for your help.
The issue was on the php side.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply