Resolved: Updating the server PHP version to 5.4 broke my Genesis Simple Sidebars plugin

I had to resolve an issue recently where a client’s hosting company had updated the PHP version of the server to 5.4 and this “broke” the plugin Genesis Simple Sidebars that was being used on their site, therefore causing the whole site to be down. The PHP error message being displayed in a browser when you tried to visit a site is what told me it was the Genesis Simple Sidebars plugin that was causing the site to be down.

I found this extremely useful thread which ultimately helped me to fix the issue – http://wordpress.org/support/topic/error-after-updating-to-php-54 – but want to outline what I did here to save others from having to scroll through the entire thread.

Step 1: Log into PHPMyAdmin or whichever interface you use to edit the database.

Step 2: Navigate to the wp_options table on the database (note: this may not be the exact name of the table, your table could be named differently depending on the $table_prefix defined in your WordPress site’s wp-config.php file)

Step 3: Navigate to the “ss_settings” field in the options table and open it to edit it.

Step 4: Remove this line of code from the beginning of the “ss_settings” content:

i:0;s:20:"__return_empty_array";

Step 5: Find the number listed right after “a:” at the beginning of the “ss_settings” content and subtract 1 from that number. So, for example, if the beginning of your “ss_settings” field looked like this:

a:37:

You will want to change it to read:

a:36:

Step 6: Save your changes to the “ss_settings” field and navigate to your website in a browser. Hopefully your site will be back up and running now!

 

MySQL: Moving columns from one table to another

Here are the steps you can use to move a column from one table to another (within the same database) using MySQL commands.

 

1) Create a new column in the table you are moving your column to. You will want it to make sure the new column is created to hold the same type of data as the column you are moving. Here is a code example:

alter table destinationtable add column destinationcolumn varchar (250) ; 

2) Now, we will copy the contents of the existing column to the new column we just created:

INSERT INTO `destinationtable`( destinationcolumn )
SELECT existingcolumn
FROM `existingtable`

3) You can also add a condition to the statement if you are moving multiple columns and need to make sure that the data is placed correctly:

UPDATE `destinationtable`,`existingtable` SET destinationtable.destinationcolumn=existingtable.existingcolumn
WHERE destinationtable.productid=existingtable.productid

 

 

Combine the values of two fields in a form into one variable to be inserted into MySQL database table

Here is the simple code that I use to combine the values of two fields in a form into one variable and insert that variable into a database table.

One example of how I used this trick was when I built an SMS-subscriber widget for a website. I needed people to enter their phone numbers into one field, select their phone carrier from another field, and then combine those two fields with an “@” symbol in between to create an email address that was then inserted into the database. These SMS subscribers could then receive the same notice as email subscribers.

Here is the code you use:

<script>
$('#insert').bind('submit', function(){
                        var phone = $('[name=phone]').val();
                        var email = $('[name=email]').val();
                        $('[name=subscriber]').val(phone+'@'+email);
                      });
</script>

Note: #insert in the code above needs to be changed to the id of your form. 

Insert the jQuery code above directly after the beginning of your form, which would look something like this:

<form action="insert.php" method="POST" id="insert">

Next, create a hidden field which will contain the combined values of the two fields:

<input type="hidden" name="subscriber"/>

And finally, create the two fields whose values you want to combine:

Phone #: <input type="text" size=25 name="phone">
Carrier: <select>
  <option name="email" value="vtext.com">Verizon</option>
  <option name="email" value="txt.att.net">AT&T</option>
</select>

In the php file that you use to process the form, you will only need to post the data from the hidden field (which contains the values of the two fields). For instance, using the example above, I would only insert the ‘subscriber’ data into the database:

$v_subscriber=$_POST['subscriber'];
... 
$query="insert into table_name(email) values('$v_subscriber')";

This would insert the value of the subscriber field (which is “phone@email” according to the jQuery above. For example: 1234567890@att.txt.net) into the email column of the table you specified.

Please let me know if you have questions or run into any issues at all.

How to change your WordPress website’s password using phpMyAdmin

Here is the way that I use to change my WordPress site’s password if I am unable to log in or reset the password to the dashboard.

Log into phpMyAdmin.

Open your WordPress database.

Select the wp_users table and click Browse.

 

 

Now click Edit on the user whose password you want to change.

You will change the password in the row user_pass.

You will notice that WordPress stores the passwords as MD5 Hash rather than plain text.

This means that you will need to use an MD5 generators online to generate your password. I use JavaScript MD5. Simply type your password in the tool and generate MD5 results.

Copy and paste the code you get from the converter into the user_pass field and click Go to save the new password.

Let me know if you run into any issues or have any questions.