CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Cannot execute --*--* drop table if exists on *new* database
Pages: [1]

Author Topic: Cannot execute --*--* drop table if exists on *new* database  (Read 3963 times)

BrightBold

  • Guest
Cannot execute --*--* drop table if exists on *new* database
January 19, 2010, 02:49:51 pm
I am having a problem installing CiviCRM 3.1b5 on a local WAMP install of Drupal 6.15. Research on this problem seems to indicate it's usually caused by installing a newer version of CiviCRM over old data; however in my case I created a brand new database specifically for this install.

I get the following error:
Quote
Cannot execute -- * -- * DROP TABLE IF EXISTS civicrm_pledge_payment; DROP TABLE IF EXISTS civicrm_participant_payment; DROP TABLE IF EXISTS civicrm_participant
{on and on for pages until}
NOT NULL COMMENT 'Pledged amount for this payment (the actual contribution amount might be different).', scheduled_date datetime NOT NULL COMMENT 'The date the pledge payment is supposed to happen.', reminder_date datetime COMMENT 'The date that the most recent payment reminder was sent.', reminder_count int unsigned DEFAULT 0 COMMENT 'The number of payment reminders sent.', status_id int unsigned , PRIMARY KEY ( id ) , INDEX index_contribution_pledge( contribution_id , pledge_id ) , INDEX index_status( status_id ) , CONSTRAINT FK_civicrm_pledge_payment_pledge_id FOREIGN KEY (pledge_id) REFERENCES civicrm_pledge(id) ON DELETE CASCADE, CONSTRAINT FK_civicrm_pledge_payment_contribution_id FOREIGN KEY (contribution_id) REFERENCES civicrm_contribution(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;: DB Error: syntax error

The only caveat to my statement that I had not previously installed CiviCRM is that at first I failed to read the manual and tried to enable the modules (for version 3.0) without having run the installer. It looked like this created one table which included the name CiviCRM in the Drupal database so I deleted that table, deleted and recreated the CiviCRM database and tried again. I still get the same error. Is there something else I should have deleted in the Drupal database? Any other ideas?

I have posted the full error message here: http://brightbold.com/civicrm-install-error.html if anyone has the time or energy to wade through it.

Thanks for any suggestions you might have.

Kelley

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Cannot execute --*--* drop table if exists on *new* database
January 19, 2010, 04:18:11 pm
The installer is trying to source the SQL script which creates the tables in your new DB - and is reporting a syntax error. Your profile indicates you are using a compatible version of MySQL - but maybe that's not the one on your laptop ?? Can you verify?

You can narrow things down a bit by dropping and recreating your new civicrm DB and then trying to load sql/civicrm.mysql directly via phpMyAdmin or from the command line. (This is not a substitute for running the installer - but would let us know if the issue is specific to your mysql install.
Protect your investment in CiviCRM by  becoming a Member!

BrightBold

  • Guest
Re: Cannot execute --*--* drop table if exists on *new* database
January 19, 2010, 05:08:49 pm
Thanks Dave - I did have a version issue that may have caused the problem (I will do the test you suggest when I get back home; I'm at the Boston CiviCRM meetup now!) I'm running on a WAMP installation that originally installed with PHP 5.3 and whatever version of MySQL that comes with that (5.1.36?). Of course Drupal doesn't run on 5.3 so I had to downgrade PHP to 5.2.11. That worked fine (with Drupal only; no Civi) but when I needed to create a new MySQL database it said that the version of MySQL was newer than what was supported by the version of PHP. So I had to downgrade MySQL to 5.0.51a. Could there be some leftover fragment of the newer version of MySQL that's causing the problem?

I could try replacing WAMP with Acquia DAMP which would install Drupal-compatible versions from the get-go.

BrightBold

  • Guest
Re: Cannot execute --*--* drop table if exists on *new* database
January 19, 2010, 07:33:27 pm
OK, I have done the test you suggested and it reports that the SQL query has been executed successfully. It has created all the tables in the database.

So what does that mean I should do next?

P.S. Hadn't realized my profile was out of date - but by accident it was reporting the correct SQL version. I have updated the other info.

BrightBold

  • Guest
Re: Cannot execute --*--* drop table if exists on *new* database
January 19, 2010, 08:40:22 pm
Someone who knows more about PHP and MySQL than I do (but who has no experience with CiviCRM or Drupal) took a look at this for me, and here's his analysis:

Quote
The problem appears to be occurring in civicrm_source function in civicrm.php. It appears that it's trying to break the sql commands into individual commands using preg_split('/;$/m', $string). However, it is not breaking the sql at all and instead just sends the entire contents of the .sql file to mysql. I tried removing the $. That allowed it to go further, but it eventually hit a point where a semi-colon that wasn't at the end of a line caused a bad break and caused it to send an incomplete insert command. My guess is that it's not matching the newline for some reason, but the semi-colons do seem to be at the end of the lines if I open the .sql files in notepad.

Is that helpful at all? Let me know what I can try next, and thanks for your help! Hopefully I can get this working by the Boston configuration training on Thursday!

Kelley

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Cannot execute --*--* drop table if exists on *new* database
January 19, 2010, 09:44:19 pm
Quote
The problem appears to be occurring in civicrm_source function in civicrm.php. It appears that it's trying to break the sql commands into individual commands using preg_split('/;$/m', $string). However, it is not breaking the sql at all and instead just sends the entire contents of the .sql file to mysql. I tried removing the $. That allowed it to go further, but it eventually hit a point where a semi-colon that wasn't at the end of a line caused a bad break and caused it to send an incomplete insert command. My guess is that it's not matching the newline for some reason, but the semi-colons do seem to be at the end of the lines if I open the .sql files in notepad.

Thanks, this is it. The preg_split('/;$/m', $string) call is definitely supposed to split stuff into lines – the ;$ matches a semicolon at the end of line and the m modifier tells PHP to work with multi-line strings (which we do in this case).

My bet is that the problem lies in the line endings on Windows and PHP not recognising that \r\n on Windows is an equivalent to \n elsewhere (or that \n in our files is an equivalent to \r\n on Windows).

If you edited the file, can you replace it with its copy from our repository and try again?
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

BrightBold

  • Guest
Re: Cannot execute --*--* drop table if exists on *new* database
January 20, 2010, 10:36:28 am
I hadn't opened or edited the file until I'd had this problem several times and we started messing around with it. Have you put a changed file in the repository or were you thinking I might have opened this file before I tried installing, causing it to be altered?

In the meantime, without having seen your reply, my aforementioned developer-husband got it to install by running all the .sql files manually and then commenting out those portions of the installer and running the rest of the install. So as far as my problem goes, I seem to be good to go now.

However, if this is a problem that will affect everyone trying to install CiviCRM on a Windows development environment, I'm sure I'm not the only one who will run across it. (And if I had to guess, those folks will, like me, be more likely than Linux users to be technical enough to play with WAMP/XAMPP phpMyAdmin but not enough to get anywhere with troubleshooting this problem on their own.) So if there are any additional tests I can run to help troubleshoot this and get it fixed, let me know. I probably won't have time until Friday or this weekend, but I would be happy to do whatever I can to help.

Thanks to you and Dave for your help!

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Cannot execute --*--* drop table if exists on *new* database
January 21, 2010, 02:26:48 am
Quote from: BrightBold on January 20, 2010, 10:36:28 am
I hadn't opened or edited the file until I'd had this problem several times and we started messing around with it. Have you put a changed file in the repository or were you thinking I might have opened this file before I tried installing, causing it to be altered?

We didn’t alter it, and I should’ve assumed that you opened it only after you hit this error – but just wanted to be sure (you might’ve opened it after hitting some other error, for example, and I’m not sure whether the tool you used didn’t alter the line endings).

Quote
In the meantime, without having seen your reply, my aforementioned developer-husband got it to install by running all the .sql files manually and then commenting out those portions of the installer and running the rest of the install. So as far as my problem goes, I seem to be good to go now.

Great, this means that the error is indeed most probably caused by the line endings. Thanks for this info!

Quote
However, if this is a problem that will affect everyone trying to install CiviCRM on a Windows development environment, I'm sure I'm not the only one who will run across it.

We’ll get a developer to test a WAMP install and will hopefully make CiviCRM installable under Windows without this kind of problems.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Cannot execute --*--* drop table if exists on *new* database

This forum was archived on 2017-11-26.