Things I can’t remember – MySQL
I’ll want to add a new field to a table and I have the data in a flat file that I’ve been working on.
For example, we recently broke words into sounds and needed to add them back to the database.
The words look like this in the BBEdit file:
a • l o t
‘a • c re
ai m s
The easies way that I’ve found to bring the sounds into the larger table is to first create a new table with id and sounds as the fields, import the sounds data, and then merge the two tables. Note: This is how it works with PHP MyAdmin. It may be slightly different from the command line.
This code imports the data into the Sounds table. Note that it ends with a semi-colon and no comma.
INSERT INTO `Sounds` (`id`, `sounds`) VALUES
(1, 'a • l o t'),
(2, 'a • c re'),
(3, 'a f • t er'),
(4, 'ai m s'),
...
(478, 'c o m • p o s t');
Now I can merge the sounds into another table in the same database by using the UPDATE command. You must include both tables after UPDATE, even though you are only updating data in one of the tables. Note that when using PHP MyAdmin you need to indicate the fields with the table name in backquotes, a dot, and then the field in backquotes. This may be different in the command line.
UPDATE `Pictures`, `Sounds`
SET `Pictures`.`sounds`=`Sounds`.`sounds`
WHERE `Pictures`.`id` = `Sounds`.`id`;
Here’s another example.
UPDATE `Pictures`, `ArticIV_Phonemes`
SET `Pictures`.`concatenated_phonemes` = `ArticIV_Phonemes`.`Concatenated_phonemes`
WHERE `Pictures`.`id` = `ArticIV_Phonemes`.`id`
Reducing WordPress Comment Spam
This blog gets dozens of comment spam. Almost all are trapped by Askimet. The funny thing about them is that few have links in the comment itself. Most have the target link in the commenters URL. I’m thinking that the best way to stop the comments is to remove the ‘Website’ field from the comment form. That field is created by the comments.php file. For some reason, it is located in the theme folder. To comment out the field, go to wp-content, themes. Then locate the theme you are using on the site. Inside that folder is a file called comments.php.
Look for the word ‘Website’. It is in this block of code.
<p><input type="text" name="url" id="url" value=
"<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
To comment it out you need to put this line before the block
<?php /*
and this line after.
*/ ?>
Your code should look like this when you are done.
<?php /*
<p><input type="text" name="url" id="url" value=
"<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
*/ ?>
I’ll report back on how well this works to reduce spam comments.
Update: 2010-10-10 Spam has now changed to link overload spam. Dozens of links in the spam post. None get thru the filter.
Update: 2011-06-20 This is my favorite spam comment of all time. Ironically it’s on this post.
Definitely believe that which you said. Your favorite reason appeared to be on the web the easiest thing to be aware of. I say to you, I certainly get annoyed while people think about worries that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people can take a signal. Will probably be back to get more. Thanks
Update: 2011-07-11 This is my new favorite spam comment. Again, on this post.
You can make money with this blog but what about a system that lets you make money without even having a website? Basically, this is an underground software that you simply have to see to believe. Imagine making money 24 hours a day without even needing a website. Imagine never having to write articles, pay for clicks, build and maintain websites, and all that. Once you see how this thing works, you will be slapping your forehead. If you are also tired of jumping through all of those hoops or if you are new to Internet marketing and would like to earn some real income online then you should check this out myspammysite.
Words
By the way, if you like words you might like my word site.
Things I can’t remember – HTML and CSS
I just stumbled upon this selector:
.preserveWS {
white-space: pre;
}
It lets you put spaces in text!