Tag Archives: URL

This is Part 2 of the article on MySQL string search and replace. This deals with searching for a sub string within a larger string in a field, update that string, and then put the large string back in the field. This is illustrated by a typical problem-How to replace HTML code tags by other tags within multiple posts in a WordPress install.

Changing HTML code tags throughout all posts in a WordPress installation.

I wanted to change the tag “code” to that of a syntax highlighter plugin I recently installed, to make my blog look pretty

First, I had to find out which table prefix was used by my site among the various multisite installs that I had.

So, go to the Database in Phpmyadmin, search for “blog.droidzone.in”

I found 7 matches inside table wp_5_options

Entering that Table, I found that the field siteurl, in table wp_5_options contained this URL. So it was evident that the tables with prefix “wp_5” contained the posts that I needed to modify.

I could then do a search within the whole database for the code tag, and then narrow down the results by those tables which had prefix wp_5.

Eureka! I found 107 matches inside table wp_5_posts for the tag.

Next I browse the results to see the field that contains this result.

I found that post_content is the field which contains posts.

So, my strategy is clear. I simply need to replace all strings which contain the code tag with the new tag.

I cant do a Mysql query on this, because I dont know how 😉

So, I export the rows containing these strings to an sql file, search and replace the tag in a text editor, and import the new sql file! 🙂

Caution: Dont choose the “Check all” followed by export! Only the first page of results will be exported in that case! You need to export everything, right? 🙂

So, choose the Export button under Query results operations, and export to sql file, then search and replace all code tags, by the target code tag.

The important thing to do before importing the results back is that the records already exist in the table so import will fail if simply imported. Instead, we need to replace the SQL statement “INSERT INTO” with the statement “REPLACE INTO ” (There is an alternate easier method-See below).

So, the following line:

INSERT INTO `wp_5_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES

becomes:

REPLACE INTO `wp_5_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES

 

Alternately, we can choose to use the REPLACE INTO statement instead of the INSERT INTO statement into the exported sql file directly from Phpmyadmin.

Summary,

  1. Phpmyadmin>Search>Word(s) or value(s) to search for (wildcard: “%”): code
  2. Inside table(s): Select All: Go
  3. Browse (result)
  4. Scroll down, Query results operations > Export
  5. Exporting rows from “wp_5_posts ” table
  6. Custom – display all possible options
  7. Dump all rows
  8. Data dump options
  9. Function to use when dumping data: REPLACE
  10. Open the exported sql file in Notepad
  11. Search and Replace All:
  12. Search: searchstring
  13. Replace:  targetstring
  14. Import sql file back

 

Voila, it’s done.

Of course SQL gurus may have easier methods to do the same. However this works for me fine. 😀

 

When everything is done, we simply import the file into the Table.

 

 

 

This is Part 2 of the article on MySQL string search and replace. This deals with searching for a sub string within a larger string in a field, update that string, and then put the large string back in the field. This is illustrated by a typical problem-How to replace HTML code tags by other tags within multiple posts in a WordPress install.

Changing HTML code tags throughout all posts in a WordPress installation.

I wanted to change the tag “code” to that of a syntax highlighter plugin I recently installed, to make my blog look pretty

First, I had to find out which table prefix was used by my site among the various multisite installs that I had.

So, go to the Database in Phpmyadmin, search for “blog.droidzone.in” by logging into phpmyadmin, then clicking on the Database, and then Search:

Phpmyadmin>MyDatabase>Search

Enter the string,
And search for “All words”

I found 7 matches inside table wp_5_options

Entering that Table, I found that the field siteurl, in table wp_5_options contained this URL. So it was evident that the tables with prefix “wp_5” contained the posts that I needed to modify.

I could then do a search within the whole database for the code tag, and then narrow down the results by those tables which had prefix wp_5.

Eureka! I found 107 matches inside table wp_5_posts for the tag.

Next I browse the results to see the field that contains this result.

I found that post_content is the field which contains posts.

So, my strategy is clear. I simply need to replace all strings which contain the code tag with the new tag.

I cant do a Mysql query on this, because I dont know how 😉

So, I export the rows containing these strings to an sql file, search and replace the tag in a text editor, and import the new sql file! 🙂

Caution: Dont choose the “Check all” followed by export! Only the first page of results will be exported in that case! You need to export everything, right? 🙂

So, choose the Export button under Query results operations, and export to sql file, then search and replace all code tags, by the target code tag.

The important thing to do before importing the results back is that the records already exist in the table so import will fail if simply imported. Instead, we need to replace the SQL statement “INSERT INTO” with the statement “REPLACE INTO ” (There is an alternate easier method-See below).

So, the following line:

INSERT INTO `wp_5_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES

becomes:

REPLACE INTO `wp_5_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES

Alternately, we can choose to use the REPLACE INTO statement instead of the INSERT INTO statement into the exported sql file directly from Phpmyadmin.

Summary,

  1. Phpmyadmin>Search>Word(s) or value(s) to search for (wildcard: “%”): code
  2. Inside table(s): Select All: Go
  3. Browse (result)
  4. Scroll down, Query results operations > Export
  5. Exporting rows from “wp_5_posts ” table
  6. Custom – display all possible options
  7. Dump all rows
  8. Data dump options
  9. Function to use when dumping data: REPLACE
  10. Open the exported sql file in Notepad
  11. Search and Replace All:
  12. Search: searchstring
  13. Replace:  targetstring
  14. Import sql file back

Voila, it’s done.

Of course SQL gurus may have easier methods to do the same. However this works for me fine. 😀

When everything is done, we simply import the file into the Table.

Update: Alternate method using SQL:

Select the database in phpmyadmin.
Execute the following query:

UPDATE wp_5_posts
SET `post_content` = REPLACE(
    `post_content`, '<pre class="lang:default decode:true ">',
       '<code>')

To see the search text, before a replacement, do:

SELECT * FROM `wp_5_posts` WHERE `post_content` LIKE '%<pre class="lang:default decode:true ">%'

For some reason, my Firefox location bar search had changed to Babylon search.

To change it back:
Open Firefox
In the addressbar, type “about:config”
Type: keyword.URL
The current keyword.URL is a link to Babylon: http://search.babylon.com/?affID=14335&tt=220512_53all&babsrc=KW_ss&mntrId=909d77c400000000000000fff812aab9&q=.

It should be changed back to the default:
http://www.google.co.in/search?ie=UTF-8&oe=utf-8&q=

I was trying to install irfanview on Kubuntu.

This was the bug description:

Executing w_do_call irfanview
Executing load_irfanview
Executing mkdir -p /home/droidzone/.cache/winetricks/irfanview
------------------------------------------------------
Checksum for /home/droidzone/.cache/winetricks/irfanview/iview428_setup.exe did not match, retrying download
------------------------------------------------------
Downloading http://www.software.com/files/iview428_setup.exe to /home/droidzone/.cache/winetricks/irfanview
--2012-04-26 22:21:50-- http://www.software.com/files/iview428_setup.exe
Resolving www.software.com... 204.51.130.11
Connecting to www.software.com|204.51.130.11|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-04-26 22:21:51 ERROR 404: Not Found.[/code]

------------------------------------------------------
Downloading http://www.software.com/files/iview428_setup.exe failed
------------------------------------------------------

First do a:
grep -n 'iview428_setup.exe' `which winetricks`

This is to find out the location (line) which we have to edit. After all, winetricks is just a script!

Find the sha1sum of the downloaded file:

sha1sum ~/downloads/iview433_setup.exe
79a7ebe2325ad204712761aa3c3a072025b07784[/code]

Then, do a which winetricks to find the location of winetricks and edit it.
That is, do:

sudo kate `which winetricks`[/code]

Copy the file to /var/www/

cp ~/downloads/iview433_setup.exe /var/www/[/code]

Edit winetricks:

w_metadata irfanview apps
title="Irfanview"
publisher="Irfan Skiljan"
year="2011"
media="download"
file1="iview433_setup.exe"
installed_file1="$W_PROGRAMS_X86_WIN/IrfanView/i_view32.exe"
homepage="http://www.irfanview.com/"[/code]

load_irfanview()
{
#w_download http://www.software.com/files/iview428_setup.exe
# a51c3f5fbb651c4c00f13c59d3de9d0f0552ea46
w_download http://files.brothersoft.com/photograph_graphics/image_viewers/iview433_setup.exe
79a7ebe2325ad204712761aa3c3a072025b07784

Note the change from iview428_setup.exe to iview433_setup.exe at the first location,
and the url change from http://www.software.com/files/iview428_setup.exe which is broken to http://localhost/iview433_setup.exe.

Of course this works only if you have LAMP installed. If you don't, just use the correct url from brothersoft. The one for iview433_setup.exe is

http://files.brothersoft.com/photograph_graphics/image_viewers/iview433_setup.exe[/code]

Cannot complete the install because one or more required items could not be found.
Software being installed: Android Development Tools 16.0.1.v201112150204-238534 (com.android.ide.eclipse.adt.feature.group 16.0.1.v201112150204-238534)
Missing requirement: Android Development Tools 16.0.1.v201112150204-238534 (com.android.ide.eclipse.adt.feature.group 16.0.1.v201112150204-238534) requires ‘org.eclipse.wst.sse.core 0.0.0’ but it could not be found

 

This error cropped up while trying to install ADT Plugin for Eclipse on Ubuntu 11.10.

Trying to install Android SDK, I got an error from the SDK Manager :

Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml, reason: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Solution to that is to:

sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 1[/code]

Update on this: Did not work with the above...Anyone know a solution?

How to Configure Apache Web Server on Linux

July 26, 2009 by 
Filed under: HowTolinuxweb development

I’ve shown previously how to install a LAMP server in Ubuntu. If the purpose of your LAMP installation was to set up your own web development environment, then you may want to do some further configuration to your system. ThisApache howto is not intended to cover Apache configuration in depth. This is just some basic configuration to help you set up a web development environment in Linux. For more information, see theofficial Apache documentation.

Why Change the Apache Configuration?

By default, Apache is set up for your web site’s files to be in the /var/www directory. This is fine if you only want to work on one website and access it through http://localhost/. But what if you want to work on several websites at the same time? Well, one solution is to create different directories under/var/www like /var/www/site1 and then access it through http://localhost/site1/. I prefer a more elegant solution.

I prefer to build websites in a directory under my own ID. I can then configure the Apache http server to point to the site directories with URLs like http://site1/http://site2/, etc.

Creating a Web Development Directory

Lets start off by creating a folder structure for the development environment. You can do this from your file manager. I prefer the terminal.

cd
mkdir webdev
cd webdev
mkdir site1 site2[/code]
We now have a directory called webdev under our home directory. Within the webdev directory are two directories called site1 and site2.

Create Some Test Files

Now we're going to create some basic test files so that we know our Apache configuration worked. Again, I'm going to use the terminal to create these files, but feel free to use your favorite text editor.

cd ~/webdev/site1
echo 'Site1 works!' > index.html
cd ../site2
echo 'Site2 works!' > index.html

Enable the Sites in Apache

OK, we're now ready to do the actual Apache configuration. Go to /etc/apache2/sites-available.

cd /etc/apache2/sites-available

As root, copy the default file as site1.

sudo cp default site1

Repeat the process to create a site2 file.

As root, edit the site1 configuration file.

sudo nano site1[/code]

Edit the file to look like this (the changes are in bold).

ServerAdmin [email protected]
ServerName site1

DocumentRoot /home/yourID/webdev/site1/

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128

[/code]

Note: The line that changes AllowOverride None to AllowOverride All is required if you want to enable URL re-writes through a .htaccess file. You need this if you want to utilize pretty permalinks in WordPress.

You now need to enable your new site.

sudo a2ensite site1

You should get a message telling you that you need to reload Apache to activate the new configuration. But first you need to edit your /etc/hosts file.

sudo nano /etc/hosts

Edit the first line adding site1 to the end of the line so it looks something like this and save the file.

127.0.0.1 localhost site1[/code]

You can now reload Apache.

sudo /etc/init.d/apache2 reload

Site1 is now enabled. Check it by browsing to http://site1/. If everything worked right, you should see a web page that says "Site1 works!"

Repeat the procedure to enable site2, etc.

Edit 12-Dec-09
If you get an error like “apache2: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for localhost,” you can fix it with this command.

echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn[/code]

Then, reload Apache to eliminate the error.

sudo /etc/init.d/apache2 reload[/code]
[/code]