Page 1 of 1

FAQ 'Access Denied' - MS SQL Issue

Posted: Mon Jul 01, 2013 10:56 am
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.

Re: FAQ 'Access Denied'

Posted: Mon Jul 01, 2013 2:16 pm
by Thorsten
Hi,

did you enable the FAQ entry?

bye
Thorsten

Re: FAQ 'Access Denied'

Posted: Mon Jul 01, 2013 10:49 pm
by BCooper
See post below.

Re: FAQ 'Access Denied'

Posted: Tue Jul 02, 2013 12:15 am
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

Re: FAQ 'Access Denied' - MS SQL Issue

Posted: Thu Jul 04, 2013 6:37 am
by Thorsten
Hi,

thanks a lot, it's fixed for 2.8.2

bye
Thorsten

Re: FAQ 'Access Denied' - MS SQL Issue

Posted: Sat Sep 14, 2013 3:06 pm
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!