Welcome, Guest
Username: Password: Remember me

TOPIC: SQL Command Failed

SQL Command Failed 2 years 7 months ago #78907

  • wasca
  • wasca's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
Hi Guys

Just did an upgrade from version 1.7.1 to 1.92.

When I got to the part where the data base is updated i this error.

====================================================================

The LimeSurvey database is being upgraded (2012-04-18 11:45:41) .Please be patient...

Moving user templates to new location at /var/www/mydomain.com/limesurvey/upload/templates...
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQL command failed: ALTER TABLE ADD `validfrom` Datetime Reason: 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 'ADD `validfrom` Datetime' at line 1

SQL command failed: ALTER TABLE ADD `validuntil` Datetime Reason: 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 'ADD `validuntil` Datetime' at line 1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Database update finished (2012-04-18 11:45:47)

Database has been successfully upgraded to version 155
Back to main menu

================================================================================

Lime survey seems to be working ok I just want to make sure that the SQL error above has not broken anything. Do I need to manually check one of my tables to see if the ADD `validfrom` and ADD `validuntil` has actually bee added?

I'm using Mysql 5.1 and php 5.3

Thanks for your help
The administrator has disabled public write access.

Re: SQL Command Failed 2 years 7 months ago #78908

  • wasca
  • wasca's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 2
  • Karma: 0
I found the code that failed. it's in /limesurvey/admin/update/upgrade-mysql.sql
// Add the reminders tracking fields
function upgrade_token_tables134()
{
    global $modifyoutput,$dbprefix;
    $surveyidquery = "SHOW TABLES LIKE '".$dbprefix."tokens%'";
    $surveyidresult = db_execute_assoc($surveyidquery);
    if (!$surveyidresult) {return "Database Error";}
    else
    {
        while ( $sv = $surveyidresult->FetchRow() )
        {
            modify_database("","ALTER TABLE ".$sv[0]." ADD `validfrom` Datetime"); echo $modifyoutput; flush();@ob_flush();
            modify_database("","ALTER TABLE ".$sv[0]." ADD `validuntil` Datetime"); echo $modifyoutput; flush();@ob_flush();
        }
    }
}

I then checked the table called lime_tokens_61558 and noticed it was missing the columns validfrom and validuntil. I manually added them in setting the type to DATETIME and with NULL values. I hope this is correct, can some one let me know if I was wrong.

Also can any one identify what is wrong with the SQL statement above and why it may have failed for me?

Thanks
The administrator has disabled public write access.

Re: SQL Command Failed 2 years 7 months ago #78936

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5426
  • Thank you received: 307
  • Karma: 252
The table name is missing after the "ALTER TABLE" part. The fields "validfrom" and "validuntil" should be added to all "lime_tokens_12345" tables (12345 = survey ID, there might be several such tables).

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.172 seconds
Donation Image