SMF Online Manual

*
  • Home
  • Community
  • Download
  • Customize
    • Modifications
    • Themes
    • Upgrades
  • Support
    • Function Database
  • Online Manual
  • About
  • Contribute
  • Development
 

Documentation of the moment:

Managing permissions on your forum


  • Home
  • Help
  • Search
  • Login
  • Register

Advertisement:
  • SMF Online Manual »
  • Glossary »
  • FAQs »
  • Installation Questions »
  • Topic: How do I fix this "ALTER TABLE smf_smileys ORDER BY LENGTH" error I am getting?
 
Install SMF Installing Upgrading Converting
Using SMF User Moderator Administrator
Advanced Mods and Themes More Info
Glossary Terminology FAQs References Feature List What's New
Comments Feedback Requests
« previous next »
How do I fix this "ALTER TABLE smf_smileys ORDER BY LENGTH" error I am getting?
While upgrading and possibly editing smileys in the Smileys section of your Administration Panel, you may get an error similar to this:

Quote
This query:
ALTER TABLE smf_smileys
ORDER BY LENGTH(code) DESC;
Caused the error:
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 'LENGTH(code) DESC' at line 2

There are two solutions to resolve this error.

The first solution will fix both the issue with upgrading, as well as an issue with editing smileys in the Smileys and Message Icons section of your admin panel.
All you need to do is update your MySQL version. To update MySQL yourself, you will have to have server access. Otherwise, and more commonly the case, you will have to ask your host to upgrade MySQL on the server for you. It is unknown at the time if the MySQL AB Team is supporting this uasge or not.

There may be other versions of MySQL that have this issue as well, but upgrading MySQL to the latest version for the MySQL branch you are using may resolve the issue.

The second way to resolve this for upgrading is to open "upgrade_1-1.sql" with a text editor and find the following:
Code: [Select]
ALTER TABLE {$db_prefix}smileys
ORDER BY LENGTH(code) DESC;

Replacing this with:
Code: [Select]
ALTER TABLE {$db_prefix}smileys
ORDER BY code DESC;

For editing smileys in the Smileys and Message Icons section of your admin panel, open "/Sources/ManageSmileys.php" with a text editor and find the following code:
Code: [Select]
// Sort all smiley codes for more accurate parsing (longest code first).
db_query("
ALTER TABLE {$db_prefix}smileys
ORDER BY LENGTH(code) DESC", __FILE__, __LINE__);

Replacing this with:
Code: [Select]
// Sort all smiley codes for more accurate parsing (longest code first).
db_query("
ALTER TABLE {$db_prefix}smileys
ORDER BY code DESC", __FILE__, __LINE__);

This section of code will appear twice in "/Sources/ManageSmileys.php", You will find this approximatively on lines 654 and 990.
Print
Reply
Reply with quote



Comments:
Quote
Kuahara made the following comment on August 23, 2008, 04:44:27 AM:

hawt... thanks for this fix.  I ran into this error today while applying the upgrade.

I'd read the guide and following the step by step instructions while paying attention to server side requirements etc...

My host (hostmonster.com) is using MySQL version 5.0.45 and php version 5.2.6

I was using the small update on the downloads page to upgrade from 1.1.4 to 1.1.5 and encountered this error.

A search in the forum lead to a user with the same issue and the first response was a link to this post.  Unfortunately 5.1 is in alpha phase atm and not actually released by sun microsystems, so there is nothing my host can do as of yet since we are using the latest version.

The second solution offered took less than 10 seconds and worked flawlessly.  Thanks a ton.


Upgrade was successfully applied to autismwf.com/forum

Quote
DMNT made the following comment on September 24, 2008, 07:25:32 AM:

I think there's another problem, that is that the default ordering is dependent on MyISAM databases and because I happen to use InnoDB I had to manually fix that default ordering into the code after transfer.

Could it be possible that the next version wouldn't use the default ordering but would have "... ORDER BY id" appended in to the php code whenever applicable?

Quote
maraja made the following comment on September 24, 2008, 08:19:16 AM:

Sometimes it is not possible to upgrade the MySQL server, please let me suggest to distribute two versions of the "upgrade_1-1.sql" and the "/Sources/ManageSmileys.php" with the proper code for both MySQL 5.0 and 5.1 and choose the proper one after having detected the sql server version.
Thank you for your great software!

Quote
lythie made the following comment on October 12, 2008, 11:41:34 PM:

Thank you very much. I also bumped into this problem.

Quote
clasione made the following comment on November 12, 2008, 12:28:48 PM:

Umm, what if you can not upgrade MySql? Wouldn't it have been nice to know that a MySQL update may be required? Now my forum is gone? I have many sites on the server using this version of mysql...

Quote
Jade made the following comment on November 12, 2008, 08:29:50 PM:

You need to do the code changes, which will eliminate the need for an upgrade :).

Quote
MagicalTux made the following comment on November 21, 2008, 12:37:52 AM:

I believe upgrading mysql is not enough.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 30334
Server version: 5.0.67-log FreeBSD port: mysql-server-5.0.67_1

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> ALTER TABLE smf_smileys     ORDER BY LENGTH(code) DESC;
ERROR 1064 (42000): 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 'LENGTH(code) DESC' at line 1


For information, 5.0.67 is the latest version of mysql in 5.0 branch.

Quote
Efser made the following comment on December 27, 2008, 07:02:51 AM:

Hi,

Can it cause a problem, when i change only the {$db_prefix}smileys table manual? So that I don't to have change the upgrade file?

Quote
Jade made the following comment on December 27, 2008, 06:17:57 PM:

If you change the ManageSmileys.php file then that should be fine if the upgrade goes smoothly :)

Quote
URAGANU made the following comment on January 13, 2009, 07:40:12 PM:

Solution is Great. I solved this problem. Thanks a lot.

Quote
Bill made the following comment on January 19, 2009, 11:40:54 PM:

It seems that this problem affects all newer MySQL versions as well? Shouldn't this be considered a bug in SMF and corrected? It seems odd that I expect an SMF upgrade to fail every time... and it does fail every time.

Quote
Jade made the following comment on January 20, 2009, 08:50:21 AM:

I think I heard someone mention it had to do with the PHP version too.

Quote
Santa made the following comment on January 31, 2009, 12:01:47 PM:

I had this Problem with a fresh install of SMF 1.1.7 on Jan 27th, 2009.

This Fixed it up! Thank You!

Quote
R dekens made the following comment on February 05, 2009, 01:46:38 PM:

i got SQL version 5.0.58 and i keep getting the same problem but i found a solution

the SQL query on this page says:

ALTER TABLE {$db_prefix}smileys
ORDER BY LENGTH(code) DESC;

and replace it with

ALTER TABLE {$db_prefix}smileys
ORDER BY code DESC;

i did that but kept getting that error.
I found 2 ways to solve this

quote out the line in the sql file and do it yourself in the database
by entering this in the SQL line:
ALTER TABLE `forum_smileys` ORDER BY `code`

or change the SQL code in the file to this:

ALTER TABLE {$db_prefix}smileys
ORDER BY `code`

both worked for me

Quote
sheryltoo made the following comment on February 05, 2009, 08:27:30 PM:

I would like to try and fix this error but I have no idea where to find the files I need to change.
Where do I find upgrade 1-1.sql?
Also, I posted a question regarding the error with the sql version on my host site and they said I should be able to upgrade the database using the latest upgrade.php file which should be located somewhere in your install of SMF.
I don't see it but maybe I'm not looking in the right place.
Sheryl

Quote
Jade made the following comment on February 06, 2009, 11:46:27 AM:

If you have this error, and are not upgrading, just change the code in the "/Sources/ManageSmileys.php" file. Don't worry about upgrade.php, that's only there when upgrading your SMF forum.

Quote
Izzet made the following comment on February 07, 2009, 02:12:58 PM:

This is a GREAT -step-by-step FIX- Thank You...

Quote
Don made the following comment on February 08, 2009, 10:02:26 PM:

what is the path to find the "upgrade_1-1.sql" via cpanel?



Quote from: maraja on September 24, 2008, 08:19:16 AM
Sometimes it is not possible to upgrade the MySQL server, please let me suggest to distribute two versions of the "upgrade_1-1.sql" and the "/Sources/ManageSmileys.php" with the proper code for both MySQL 5.0 and 5.1 and choose the proper one after having detected the sql server version.
Thank you for your great software!

Quote
Jade made the following comment on February 08, 2009, 11:04:46 PM:

When upgrading, it is in the root of the forum

Quote from: Jade on February 06, 2009, 11:46:27 AM
If you have this error, and are not upgrading, just change the code in the "/Sources/ManageSmileys.php" file. Don't worry about upgrade.php, that's only there when upgrading your SMF forum.

Quote
tiggsy made the following comment on February 13, 2009, 12:31:07 PM:

The problem is, I don't have a {whatever}_smf_smileys table, so no amount of alteration to code accessing it, altering it or whatever is going to prevent this error.

Please supply the structure of the table, so i can create it manually.

Quote
Jade made the following comment on February 13, 2009, 05:05:09 PM:

You should have a PREFIX_smileys table. Go to the database used for SMF, find the prefix you used on the install page (default is "smf_") then select the table. In the new window hit "SQL". I believe you can hit SQL in the db and run that query without going into the table too :).

Also, please read the comments above and see if any helps you :).

Quote
BLue fire made the following comment on March 11, 2009, 02:25:55 PM:

bro i never find any code you mentioned above in upgrade.php file.i also download managesmiley.php file and replace the text you mentioned above and upload again but its give me a same error please help me my forum is a live forum with many members.if this problem occured from smilies tell me how to remove smilies and also my forum goes in maintenance stage tell me how to come back in normal stage before we find solutions for this please help :(

Quote
Jade made the following comment on March 14, 2009, 12:27:46 PM:

Maintenance mode is in server settings.

You need to clear your cache if you have it, through forum maintenance.


Also, the manage smileys code appears several times in the file.

Quote
wishes_pending made the following comment on May 11, 2009, 04:33:13 PM:

I really must be a total idiot because i don't see in my forum under smileys and messag icons where this code it your speaking of... This is so frustrating..

Quote
Jade made the following comment on May 24, 2009, 12:20:13 PM:

You need to access the files via FTP :).

How do I use FTP? / What is FTP?

Quote
De Kus made the following comment on June 21, 2009, 05:26:59 PM:

I don't think it is approviate to required MySQL 5.1 to run the default upgrade system. On our servers where I dist-upgraded to debian stable (lenny) the current MySQL version is 5.0.51a-24+lenny1. I'd consider this a recent stable version which is surely widely used (i. e. on most production debian based servers).


Advertisement:
  • Powered by SMF 2.0 RC3 - REV 9736 | SMF © 2006–2010, Simple Machines LLC
  • XHTML
  • RSS
  • WAP2

Page created in 0.103 seconds with 17 queries.
Page served by: 10.0.100.134