• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

You have an error in your SQL syntax

Firetrak

Member
i'm trying to fix a slow down on my wordpress website and i'm getting this error, but i really dont know what it means, there is no "if" statement in line one, hopefully someone might have an idea to help me.

MysqlError: 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 'IF' at line 1

Sample stack trace
in mysql_query called at /home/nailedmagazine/public_html/wp-includes/wp-db.php (1663)
…db::_do_query called at /home/nailedmagazine/public_html/wp-includes/
wp-db.php (1567)
in wpdb::query called at /home/nailedmagazine/public_html/wp-includes/wp-db.php (1953)
…sults called at /home/nailedmagazine/public_html/wp-admin/includes/
upgrade.php (1694)
…led at /home/nailedmagazine/public_html/wp-content/themes/nailed/
functions.php (127)
in na_create_posts_views_table called at ? (?)
…r_func_array called at /home/nailedmagazine/public_html/wp-includes/
plugin.php (496)
in do_action called at /home/nailedmagazine/public_html/wp-settings.php (374)
in require_once called at /home/nailedmagazine/public_html/wp-config.php (103)
in require_once called at /home/nailedmagazine/public_html/wp-load.php (29)
in require_once called at /home/nailedmagazine/public_html/wp-blog-header.php (12)
in require called at /home/nailedmagazine/public_html/index.php (17)
 
we won't really be able to tell you what the error is if you don't tell us what the sql syntax of the query is.

or at least copy/paste the code included in line 1663 of wp-db.php
 
Just googling around I see incidences of similar errors going back over nine years. Appears to usually be related to a specific version of a component. Are all your plugins updated?
 
i think it might have something to do with a plugin called WP-PostViews that was no longer installed, i see a table in myphpadmin called wp_post_views that i think was left behind, this table is 36mb in size, all other tables are maybe 200kb in size.

If i empty this table do you think it might help?
 
Also this query

$this->query( $query );

Seems to be the main one causing issues, but I dont really know what it means, its on 3 lines in the .php file and its the one causing the issues.
 
i'm trying to fix a slow down on my wordpress website and i'm getting this error, but i really dont know what it means, there is no "if" statement in line one, hopefully someone might have an idea to help me.

MysqlError: 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 'IF' at line 1

Sample stack trace
in mysql_query called at /home/nailedmagazine/public_html/wp-includes/wp-db.php (1663)
…db::_do_query called at /home/nailedmagazine/public_html/wp-includes/
wp-db.php (1567)
in wpdb::query called at /home/nailedmagazine/public_html/wp-includes/wp-db.php (1953)
…sults called at /home/nailedmagazine/public_html/wp-admin/includes/
upgrade.php (1694)
…led at /home/nailedmagazine/public_html/wp-content/themes/nailed/
functions.php (127)
in na_create_posts_views_table called at ? (?)
…r_func_array called at /home/nailedmagazine/public_html/wp-includes/
plugin.php (496)
in do_action called at /home/nailedmagazine/public_html/wp-settings.php (374)
in require_once called at /home/nailedmagazine/public_html/wp-config.php (103)
in require_once called at /home/nailedmagazine/public_html/wp-load.php (29)
in require_once called at /home/nailedmagazine/public_html/wp-blog-header.php (12)
in require called at /home/nailedmagazine/public_html/index.php (17)

You have the stack trace so open up /home/nailedmagazine/public_html/wp-includes/wp-db.php, go to line 1663, and echo out the actual query to see what's going on... after determining what the syntax error is, you have to back track from the stack trace and look at source code to see which file is building the query incorrectly.
 
hi uclabachelor could you elaborate i'm not sql proficient at all.

this is the actual query: $this->query( $query );
 
hi uclabachelor could you elaborate i'm not sql proficient at all.

this is the actual query: $this->query( $query );

Right before that line, add:

Code:
echo $query;
die();

and post the contents of the output on the web page on here... don't forget to undo your changes to that file when you're done with it.
 
Also this query

$this->query( $query );

Seems to be the main one causing issues, but I dont really know what it means, its on 3 lines in the .php file and its the one causing the issues.

that is not the actual query, that is the php code. you have to tell use what the value of $query is.
 
Back
Top