You have an error in your SQL syntax

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Anti-Spam Guide
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
kamikazecow
Registered User
Posts: 10
Joined: Fri Nov 05, 2010 10:22 pm

You have an error in your SQL syntax

Post by kamikazecow »

I have tried to clear cache, to move a fresh install from another server where phpBB3 is working fine, to rename htacces, to change file permissions, install and convert phpBB2 ( http://egermuzeum.hu/phpBB2/) to phpBB3 (http://egermuzeum.hu/_forum/) but nothing happened except for this error message:

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 'AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imag' at line 4 [1064]

Thank you in advance for any help!
User avatar
AmigoJack
Registered User
Posts: 5739
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: You have an error in your SQL syntax

Post by AmigoJack »

Open /includes/session.php and find the following lines:

Code: Select all

        else
        {
            // Set up style
            $style = ($style) ? $style : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']);
        } 
After that, add:

Code: Select all

        if( !$style ) $style= $config['default_style']; 
If the error still remains, execute these two SQL commands and post back the results:

Code: Select all

SELECT config_value FROM phpbb_config WHERE config_name= 'default_style';
SELECT style_id FROM phpbb_styles;
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
kamikazecow
Registered User
Posts: 10
Joined: Fri Nov 05, 2010 10:22 pm

Re: You have an error in your SQL syntax

Post by kamikazecow »

AmigoJack wrote:Open /includes/session.php and find the following lines:
It didn't work unfortunately.
AmigoJack wrote:

Code: Select all

SELECT config_value FROM phpbb_config WHERE config_name= 'default_style';
SELECT style_id FROM phpbb_styles;
Here is the print screen after query:

Image

Thank you for your help!
User avatar
AmigoJack
Registered User
Posts: 5739
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: You have an error in your SQL syntax

Post by AmigoJack »

AmigoJack wrote:execute these two SQL commands
You have to do that always one by one and give the result of each.

Anyway, execute this SQL command and see if the error still remains:

Code: Select all

UPDATE phpbb_config SET config_value= '2' WHERE config_name= 'default_style'
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
kamikazecow
Registered User
Posts: 10
Joined: Fri Nov 05, 2010 10:22 pm

Re: You have an error in your SQL syntax

Post by kamikazecow »

AmigoJack wrote:
AmigoJack wrote:execute these two SQL commands
You have to do that always one by one and give the result of each.[/code]
I am not a wizard of php/sql. :oops: :)


I ran the query, and I got another error message:
SQL ERROR [ mysqli ]

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 'AND t.template_id = s.template_id AND c.theme_id = s.theme_id AND i.imag' at line 4 [1064]


Thank you for your help!
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10391
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: You have an error in your SQL syntax

Post by Noxwizard »

You will need to purge the cache for that query to go into effect. (Delete all files except index.htm and .htaccess from /cache/). If that still doesn't fix it, download the Support Toolkit and run the following tools: Emergency Repair Kit (main page), Sanitise Anonymous User (support tab), and Reset Styles (support tab).
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
kamikazecow
Registered User
Posts: 10
Joined: Fri Nov 05, 2010 10:22 pm

Re: You have an error in your SQL syntax

Post by kamikazecow »

Noxwizard wrote:...run the following tools: Emergency Repair Kit
I emptied the cache and I tried to run the toolkit, but I got a message:
Emergency Repair Kit
The Support Toolkit encountered a fatal error.

When I clicked the menu on the right top (Emergency repair tool kit or something), nothing happened, except for the empty screen. ( http://egermuzeum.hu/_forum/stk/). I tried to re-upload the files but it did not help.
I tried to change the php version to 4.x but it did not help either.

@Noxwizard: if it is needed I send you the ftp/sql user/pass in pm.

Thank you very much.
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: You have an error in your SQL syntax

Post by Erik Frèrejean »

Blank screens are suppressed php errors, you'll have to look at the php error logs to find out what is causing this problem. Usually you'll be able to see the logs through your hosts control panel, if you can't find it there you'll have to contact your host.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
kamikazecow
Registered User
Posts: 10
Joined: Fri Nov 05, 2010 10:22 pm

Re: You have an error in your SQL syntax

Post by kamikazecow »

Erik Frèrejean wrote:Blank screens are suppressed php errors, you'll have to look at the php error logs to find out what is causing this problem. Usually you'll be able to see the logs through your hosts control panel, if you can't find it there you'll have to contact your host.
It would seem that my host can't help me. I can't tell him the problem exactly because I don't know the problem :) (and Joomla, phpBB2 is working fine for example). I give it up. Thank you for all your help!:)
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: You have an error in your SQL syntax

Post by Erik Frèrejean »

kamikazecow wrote: I can't tell him the problem exactly because I don't know the problem :)
The problem is that you need the error logs in order to determine what the error is ;).
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
yukon4
Registered User
Posts: 6
Joined: Mon Mar 21, 2011 10:23 pm

Re: You have an error in your SQL syntax

Post by yukon4 »

We have a similar error message regarding SQL syntax. This is what we get when attempting to view our forum. This is AFTER successfully repairing a few corrupted tables:

SQL ERROR [ mysqli ]

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 ') ) AND t.forum_id = 0 ORDER BY t.topic_last_post_time DESC LIMIT 1' at line 5 [1064]


I'm posting to ask if going to our "includes/session.php" file and making the changes described in another post on this page might help us???

Thank you!
yukon4
Registered User
Posts: 6
Joined: Mon Mar 21, 2011 10:23 pm

Re: You have an error in your SQL syntax

Post by yukon4 »

AmigoJack wrote:Open /includes/session.php and find the following lines:

Code: Select all

        else
        {
            // Set up style
            $style = ($style) ? $style : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']);
        } 
After that, add:

Code: Select all

        if( !$style ) $style= $config['default_style']; 
If the error still remains, execute these two SQL commands and post back the results:

Code: Select all

SELECT config_value FROM phpbb_config WHERE config_name= 'default_style';
SELECT style_id FROM phpbb_styles;


Will the above also work for the following error:
SQL ERROR [ mysqli ]

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 ') ) AND t.forum_id = 0 ORDER BY t.topic_last_post_time DESC LIMIT 1' at line 5 [1064]
User avatar
AmigoJack
Registered User
Posts: 5739
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: You have an error in your SQL syntax

Post by AmigoJack »

No, that won't help you.
yukon4 wrote:what we get when attempting to view our forum
This is too imprecise:
  1. What are you doing to encounter this error message? (viewing the index, viewing a forum, viewing a topic, viewing the UCP... or really all of it?). Which in turns also tells us which parts of your board do work as intended.
  2. Provide basic information.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
yukon4
Registered User
Posts: 6
Joined: Mon Mar 21, 2011 10:23 pm

Re: You have an error in your SQL syntax

Post by yukon4 »

Hello,

We got that Syntax message when simply going to our forum homepage. (www.teachsoap.com/forum) Prior to that, we received error messages about the database tables, such as the "users" table having crashed.

We successfully repaired the tables, but now suspect something "weird" happened in the crash as the vast majority of users have been deleted!! Because the users were somehow deleted, none of their posts are displaying.

The only other thing we did was clear the "cache", as suggested by tech support at our host (Pair Networks - very knowledgeable folks) We did this by running a "clear the cache" script found on this forum.

It's a mess. At this point, we are hoping to restore from a database backup done back on March 18. We'll lose maybe 2 days of posts, but hopefully will regain a few thousand users!

Does it sound like perhaps we got hacked? Clearing the forum cache wouldn't wipe out most of our users would it??
yukon4
Registered User
Posts: 6
Joined: Mon Mar 21, 2011 10:23 pm

Re: You have an error in your SQL syntax

Post by yukon4 »

P.S.

Here is the script we ran to clear the cache. I removed it after running it:

http://www.phpbb.com/community/viewtopi ... &t=1461565
Locked

Return to “[3.0.x] Support Forum”