FAQ 'Access Denied' - MS SQL Issue

All about webserver configurations, PHP and databases.

Moderator: Thorsten

Post Reply
BCooper
Posts: 19
Joined: Mon Jul 01, 2013 10:37 am

FAQ 'Access Denied' - MS SQL Issue

Post by BCooper »

Hi,

I have just setup phpMyFAQ 2.8.1 on Windows 2008 R2 (IIS 7.5) with PHP 5.4 using a SQL 2008 R2 backend and it appeared to install ok and was able to login and create categories etc.

However when I create a new FAQ it saves but when trying to edit (action=editentry&id=2), the question is missing and inside the text box for the answer it just says 'Access denied.'.

When you are in the 'Edit Existing FAQs' screen the questions show up ok but once in the edit screen it has the access denied. Same thing happens when accessing the FAQ from the front end, you can see the question title but when you click to view the FAQ the question text is missing and the text body just says 'Access denied.'

I am logged in as the admin account. When logged out I also am unable to view the faq.

Any ideas?

Cheers.
Last edited by BCooper on Tue Jul 02, 2013 6:57 am, edited 1 time in total.
Thorsten
Posts: 15561
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: FAQ 'Access Denied'

Post by Thorsten »

Hi,

did you enable the FAQ entry?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
BCooper
Posts: 19
Joined: Mon Jul 01, 2013 10:37 am

Re: FAQ 'Access Denied'

Post by BCooper »

See post below.
Last edited by BCooper on Tue Jul 02, 2013 12:31 am, edited 1 time in total.
BCooper
Posts: 19
Joined: Mon Jul 01, 2013 10:37 am

Re: FAQ 'Access Denied'

Post by BCooper »

Ok, I have done some poking around.

File: \inc\PMF\Faq.php
Line 714: if ($row = $this->_config->getDb()->fetchObject($result)) {

Tries to fetch the object, otherwise returns a generic 'Access Denied.' record. This is what is happening.

So i grabbed the $query it was using as part of $result:

Code: Select all

SELECT DISTINCT id, lang, solution_id, revision_id, active, sticky, keywords, thema, content, author, email, comment, datum, links_state, links_check_date, date_start, date_end FROM faqdata fd LEFT JOIN faqdata_group fdg ON fd.id = fdg.record_id LEFT JOIN faqdata_user fdu ON fd.id = fdu.record_id WHERE fd.id = 2 AND fd.lang = 'en' AND 1=1
Ran the query in SQL Server Management Studio (SQL Server 2008 R2) against the phpMyFAQ database:

Msg 421, Level 16, State 1, Line 1
The text data type cannot be selected as DISTINCT because it is not comparable.
Msg 421, Level 16, State 1, Line 1
The text data type cannot be selected as DISTINCT because it is not comparable.
Msg 421, Level 16, State 1, Line 1
The text data type cannot be selected as DISTINCT because it is not comparable.


Appears the query is not valid for MS SQL, it does not like DISTINCT for that data type.

If I remove DISTINCT from the query (line 683 of the file mentioned above) the system is now working.

Issue raised: https://github.com/thorsten/phpMyFAQ/issues/712
Thorsten
Posts: 15561
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: FAQ 'Access Denied' - MS SQL Issue

Post by Thorsten »

Hi,

thanks a lot, it's fixed for 2.8.2

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
cdsaenz
Posts: 3
Joined: Sat Sep 14, 2013 2:59 pm

Re: FAQ 'Access Denied' - MS SQL Issue

Post by cdsaenz »

Hello, I'm starting up a FAQ with SQL Server Express 2012 and using 2.8.2

However I'm having the same object issue that BCooper reported. I see that the Faq.php code now generates something like:

Code: Select all

SELECT id, lang, solution_id, revision_id, active, sticky, keywords, 
	thema, content, author, email, comment, datum, links_state, links_check_date, date_start, date_end 
	FROM faqdata fd 
	LEFT JOIN faqdata_group fdg ON fd.id = fdg.record_id 
	LEFT JOIN faqdata_user fdu ON fd.id = fdu.record_id 
	WHERE fd.id = 1 AND fd.lang = 'en' AND 1=1 
	GROUP BY fd.id
When testing the code in SQL Mgmt Studio I had to to take off the "GROUP BY" portion above, else I should have added all the fields in the select to the GROUP BY. I don't think the GROUP BY is needed anyway as a single record should be returned, unless I'm missing something. Now works like a charm, thanks!
Post Reply