WordPress install error : “Table Prefix” must not be empty

I have spent some time today facing “Table Prefix” must not be empty error on step 2 of setup (right after submitting database parameters ).  During investigations it has resulted that $_POST was empty , even if the html code of the form was correct and browser headers showed that post data was sent:

headersSearching the web for a solution resulted in only one related result ( out of many ) and it was related to upload_max_filesize and post_max_size php settings.
However, it didn`t feel like it has anything to do with my problem since i had not changed any settings for some time and i had installed wordpress multiple times with the exact settings that were in place at the time the error occurred.

I have considered using an “older” version o wordpress that worked last time (actually the current version but downloaded a few days ago ). Still same problem.

Only after i have looked into the headers i have noted that even if the page showing the “Table Prefix” must not be empty error looked fine in browser , the server actually serverd it with a HTTP/1.1 500 Internal Server Error error and convinced me to look into the server logs, where i have found that there was a PHP Warning: Unknown: POST Content-Length of 86 bytes exceeds the limit of -2147483648 bytes in Unknown on line 0 error.

In the end it has proved that the problem was in fact related to those upload_max_filesize and post_max_size php settings but it didn`t showed till now. Lowering the values of these settings solved it. I suppose the the problem didn`t showed till not because there was enough memory available to be used last time but todey somehow the server was using more memory and it wasn`t ebough left and because of that it trowed the error ( my server has 2G of memory and usually it uses about 850M ). The settings were set just to high i suppose.

So , if you read this post because you have the same problem, first thing you should to is to try lowering your post_max_size php settings .

Windows 7 startup folder

Switched from Windows XP to Windows 7 a while ago , however never needed this since now . I wanted to add a program to startup (usually a remove programs from there ) and the easiest was to do it is by placing a shortcut into startup folder ( the other one i know is to add a registry entry ).

Well , i knew where that folder was on Windows XP but on Windows 7 is no longer there . I have found it that in Windows 7 the location of your personal startup folder is:

%systemdrive%\users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

For all users, you will find the startup folder in:

%systemdrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

Move wordpress network from subdomain to subfolders

A client of mine needed to convert a wordpress network from using subdomains to subfolders ( instead of *.site.com he wanted to have site.com/* , meaning that instead of site1.site.com he wanted site.com/site1 ). Task seems really easy in the beginning (when you install network wordpress interface asks you how you want the network to work — subdomain or subfolders — and that`s it ).
But if you want to change that it`s not that simple since wordpress interface has no such option and you need to do it manually ).
Anyway , after some missed settings i have succeed converting it .
These is what you need to do in order to convert the wordpress network (multisite) from using subdomains to sub subfolders :

    1. BACKUP EVERYTHING

Change wordpress configuration file

    1. ftp login to server and edit wp-config.php . Change define(‘SUBDOMAIN_INSTALL’, true); to define(‘SUBDOMAIN_INSTALL’, false);

Change wordpress database

  1. login to phpmyadmin (if you are using cpanel there is a link to it under DATABASES group), select wordpress network databaseand perform the following:
    • select table blogs ( actually it is named wp_blogs if you didn`t change default prefix.
      For each subsite you have a line in that table . For each site (except blog id 1 )  you need to change  domain and path .
      As an example you have the following lines into that table :

      blog_id site_id domain path registered last_updated public archived mature spam deleted lang_id
      1 1 www.site.com / 2011-04-01 03:35:42 2012-02-14 07:40:38 1 0 0 0 0 0
      14 1 harukoyama.site.com / 2011-04-27 16:02:26 2011-08-06 18:04:55 1 0 0 0 0 1
      87 1 cameron.site.com / 2011-07-28 16:59:52 2011-08-05 16:41:18 1 0 0 0 0 0
      12 1 samantha.site.com / 2011-04-27 16:01:07 2011-04-27 16:01:13 1 0 0 0 0 1

      You need to edit all of them (except the one with id 1 witch is main site and must remain as it is ) and change domain and path. Domain should be the main site domain and path should be the subfolder used for that subsite. So , you will need to change that table to this one :

      blog_id site_id domain path registered last_updated public archived mature spam deleted lang_id
      1 1 www.site.com / 2011-04-01 03:35:42 2012-02-14 07:40:38 1 0 0 0 0 0
      14 1 www.site.com /harukoyama/ 2011-04-27 16:02:26 2011-08-06 18:04:55 1 0 0 0 0 1
      87 1 www.site.com /cameron/ 2011-07-28 16:59:52 2011-08-05 16:41:18 1 0 0 0 0 0
      12 1 www.site.com /samantha/ 2011-04-27 16:01:07 2011-04-27 16:01:13 1 0 0 0 0 1

    Now , for each line changed in the table you need to get blog_id value (they are marked in red in last table to be easy to spot). For each blog_id that you changed you need to select options table that belongs to it . For blog_id 14 there is a wp_14_options table into the database . For blog_id 87 there is a wp_87_options table also. etc. You need to browse to each of that options table and locate the lines where column OPTION_NAME is ‘home’ and ‘siteurl’.

    As an example , let`s suppose you will find the following lines for blog_id 12 :

    option_id option_name option_value autoload
    1 siteurl http://samanta.site.com/ yes
    37 home http://samanta.site.com/ yes

    You need to change these lines to:

    option_id option_name option_value autoload
    1 siteurl http://site.com/samanta/ yes
    37 home http://site.com/samanta/ yes

This is what i tough it was all but there was one more step to do . Luckily , the client sow it and signaled it to me.

Change .htaccess redirect options

The main problem was related to the fact that some posts on subsites had embedded files (images) that were uploaded when each post was written . These files were inserted to post with static links pointing to old subdomain settings , meaning that when the subsite was using the url http://samantha.site.com images were inserted as http://samantha.site.com/files/2011/08/image.jpg . Since subdomain is no longer working images won`t show. What was needed to be done was to change the image link for each files embedded into post to http://www.site.com/samantha/files/2011/08/image.jpg .
That meant to parse each post for each subsite and change links . However , since that link is not actually served from a physical location on the server but it is redirected in .htaccess to wp-includes/ms-files.php, all i had to do was to change redirect condition in .htaccess file.

So what you need to do is to fpt login into the server , browse for site root folder and edit .htaccess file.
Locate the following line :

RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

Replace it with the following 2 lines :
RewriteCond %{HTTP_HOST} !(www)\.site\.com$ [NC]
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) http://www.site.com/$1/wp-includes/ms-files.php?file=$2 [L]

That means :

if requested domain is not www.site.com but some other subdomain ( eg. samantha.site.com ) it will redirect the request to http://www.site.com/[subdomain]/wp-includes/ms-files.php ( as in eg. the link will be http://www.site.com/samantha/wp-includes/ms-files.php

That`s all

MySQL – Copiaza o baza de date de pe un server pe altul direct din consola

In cele mai frecvente cazuri folosesc mysqldump pentru a obtine un backup al bazei de date pe care apoi il utilizez pentru a crea baze de date.
Desi este destul de buna ca solutie , in cazul in care pur si simplu dorim sa “clonam” o baza de date pe alt server evine putin incomod .

Solutia gasita este sa setez serverul MySQL pe care doresc sa pun baza de date sa accepte conexiuni de la sererul pe care se afla deja baza de date ( restrictii pe host/ip ) , si apoi sa execut urmatoarea comanda pe serverul pe care se afla deja baza de date:

mysqldump -u<USER1> -p<PAROLA1> <BAZA_DE_DATE_1> | mysql -u<USER2> -p<PAROLA2> –host=<IP_SERVER2> -C <BAZA_DE_DATE2>

mysqldump -hIP -uUSER -pPASSWORD DATABASE | mysql -uUSER -pPASSWORD -hIP -C DATABASE

UNDE:

USER1 , PAROLA1 , BAZA_DE_DATE1 corespund serverulul de pe care doresc sa copiez/clonez

USER2 , PAROLA2 , IP_SERVER2 si BAZA_DE_DATE2 corespund serverului pe care doresc  sa fie copiata baza de date.

Atentie asupra faptului ca ca pe SERVER2 trebuie sa existe deja o baza de date creata cu numele BAZA_DE_DATE2 iar USER2 trebuie sa aiba deja acces la respectiva baza de date.

MySQL – Conversie toate tabelele la INNODB

Rezolvare rapida a problemei conversiei tuturor tabelelor la InnoDB . Pentru cazul in care sunt suficient de putine se poate rezolva usor din phpMyAdmin insa in cazul in care discutam de mai multe … jumatate de zi de click-uri in phpMyAdmin s-ar putea sa nu fie chiar asa atragator.

In consola tastatzi urmatorul rand (evident dupa ce anterior ati inlocuit <USER> , <PAROLA> SI <DATABASE>cu ceea ce aveti nevoie.

for t in `echo “show tables” | mysql -u<USER> -p<PAROLA> –batch –skip-column-names <DATABASE>`;
do mysql -u<USER> -p<PAROLA> <DATABASE> -e “ALTER TABLE \`$t\` ENGINE = InnoDB;”;  done ;