Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Fatal Error: "You have an error in your SQL syntax"

ispjstfuispjstfu New
edited April 2014 in Vanilla 2.0 - 2.8


I'm new to Vanilla and new to this forum, but I would love to get some help with an error I'm getting...

I installed Vanilla locally to try it out for the first time, after some initial kinks with my Mac not transferring the .htaccess file, it all worked, I realized I liked it, and decided to use it on a website I'm building.

So... I made a fresh install at a subdomain, exported the forum with the categories I had created on my local install, and imported it into the live site, and it all seemed to work, except for the fact that I want my forum to be private, and not visible at all to guests, so I went in to the Roles & Permissions settings, and as soon as I try to edit or add a user role, I get this error:

Fatal Error in Gdn_Database.Query();

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' p.Name as `Name` from GDN_c c left join GDN_p p on c. = p.ID' at line 1
select distinct p.ID as `ID`, c., p.Name as `Name`
from GDN_c c
left join GDN_p p on c. = p.ID
The error occurred on or near: /storage/content/73/117673/
283:          $PDOStatement = $this->Connection()->query($Sql);
284:       }
286:       if ($PDOStatement === FALSE) {
287:          trigger_error(ErrorMessage($this->GetPDOErrorMessage($this->Connection()->errorInfo()), $this->ClassName, 'Query', $Sql), E_USER_ERROR);
288:       }
290:       // Did this query modify data in any way?
291:       if ($ReturnType == 'ID') {
[/storage/content/73/117673/] PHP::trigger_error();
[/storage/content/73/117673/] Gdn_Database->Query();
[/storage/content/73/117673/] Gdn_SQLDriver->Query();
[/storage/content/73/117673/] Gdn_SQLDriver->Get();
[/storage/content/73/117673/] PermissionModel->GetJunctionPermissions();
[/storage/content/73/117673/] PermissionModel->GetPermissions();
[/storage/content/73/117673/] PermissionModel->GetPermissionsEdit();
[/storage/content/73/117673/] RoleController->Edit();
[/storage/content/73/117673/] PHP::call_user_func_array();
[/storage/content/73/117673/] Gdn_Dispatcher->Dispatch();
Variables in local scope:
[Sql] 'select distinct p.ID as `ID`, c., p.Name as `Name`
from GDN_c c
left join GDN_p p on c. = p.ID'
[InputParameters] array (
[Options] array (
  'ReturnType' => 'DataSet',
[ReturnType] 'DataSet'
[PDOStatement] false
Need Help?
If you are a user of this website, you can report this message to a website administrator.
If you are an administrator of this website, you can get help at the Vanilla Community Forums.
Additional information for support personnel:
Application: Vanilla
Application Version:
PHP Version:
Operating System: Linux
Server Software: Apache/2.2.22 (Ubuntu)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
Request Uri: /index.php?p=/role/edit/8
Controller: Gdn_Database
Method: Query

What does it mean, and what do I do? I tried to replace the file "class.database.php" entirely, both from a fresh Vanilla folder, and from my old local one (that worked, and did not do this) as the only thing I could figure out from all of the stuff above is that the error has something to do with that file...

If anyone feels like they can help me out and get this issue sorted out I would be eternally grateful, as I really wanna use Vanilla, and worked really hard to get everything up an running, but have to figure this out in order to be able to continue with using Vanilla as my forum solution.



  • Options

    try a new install of - with security fixes.

    when transferring code from one site to another,

    always clear the ini files in the cache.

    and run utility/structure and utility/upgrade.

    those three things usually fix most problems.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Thanks! I ended up reinstalling everything, with the newer Vanilla and added my custom theme, which all worked, and then when I imported the old forum, the problem came back, and persisted even after clearing the ini files in the cache.

    ... So I deleted all files from the FTP, cleared the database, installed it all again, and manually created all the categories again, which actually turned out to be better. Now it all works!

    Fortunately there were no discussions in the forum this time, but if I have to move it all in the future, with discussions, I really hope it doesn't cause the same trouble.

  • Options

    Ok, focus on this line : select distinct p.ID as ID, c., p.Name as Name See the c., ?? There's your problem. If you really want to fix this for next time you need to keep your old backup that you restored and the problem came back... Because that way you can reproduce the problem for a bug report.

    There was an error rendering this rich post.

  • Options
    LincLinc Detroit Admin

    After importing, you should always run /utility/update again.

    What are you importing from?

  • Options
    chanhchanh - CMS Researcher ✭✭
    edited April 2014

    I agree with @UnderDog I don't think "c." is a valid SQL statement.

    select distinct p.ID as ID, c., p.Name as Name

Sign In or Register to comment.