I need more Coffee Spam

Written by: burt
Date: October 25, 2006
Filed under: Life of Burt
Trackback

Overnight this blog was spammed by a bunch of spammers promoting some coffee site. The text of their posts was ripped from wikipedia. The good thing about Wordpress is that I have the Akismet plugin installed which stops most of the spam, dead.

Anyway - these spammers must have been onto something, as I definitely need more coffee this morning. I've been working on a small script which uses XMLRPC and PHP. PHP is not new to me, I've been working with it on and off for about 4 years. But XMLRPC is very new - and my script just was not working at all. After an hour of combing through the code I found the code that wasn't working.

When checking the length of a string, make sure that you use speech marks around the number;

if (strlen($whatever) > 0) {
do something;
}

Whereas, this will work;

if (strlen($whatever) > "0") {
do something;
}

So, there was I, assuming I was struggling with XMLRPC, when all the time the bloddy problem was my lack of speech-marks. Ho hum.

Spammers, what was that coffee URL again?

Comments

  1. Comment by Anonymous Coward — October 25, 2006 @ 5:00 pm

    I don't understand - strlen returns an integer. What difference does it make? Are you sure you didn't change something else?

  2. Comment by burt — October 26, 2006 @ 10:49 am

    AC, that is my experience, but for this test, it just would not work without the quotes for whatever reason. V strange.

  3. Comment by Lea — November 2, 2006 @ 5:37 am

    I strlen check fields constantly and haven't ever quoted the numeric comparator, so there must be something else happening here.
    strlen returns an int, so it is casting the "0" anyway.
    ?

  4. Comment by burt — November 2, 2006 @ 11:38 am

    I needed more coffee :)

    define('SITE_NAME', 'name');
    define('RSSFEED', 'feed');
    if (strlen(SITE_NAME > "0") && strlen(RSSFEED > "0")) {
    echo "burt is skill";
    }
    else {
    echo "burt sucks";
    }

    and

    define('SITE_NAME', 'name');
    define('RSSFEED', 'feed');
    if (strlen(SITE_NAME > 0) && strlen(RSSFEED > 0)) {
    echo "burt is skill";
    }
    else {
    echo "burt sucks";
    }

    DOH!

  5. Comment by Lea — November 2, 2006 @ 1:42 pm

    You do realise that you havent enclosed just the field in the strlen in the example, don't you?
    :)
    The code in the post was fine, though, so I still don't know what you might have done :)

  6. Comment by burt — November 2, 2006 @ 11:33 pm

    The other part of the script, the actual;

    {
    do something
    }

    didn't work anyway. I need to find a developer who knows XMLRPC to move forwards on it. If anyone does know someone who can handle creating an XMLRPC call, lemme know - cash is waiting!

Sorry, the comment form is closed at this time.


Did you enjoy reading this?
Please consider subscribing to our RSS Feed!


Subscribe by Email
Get notified by email every time we update this Blog!


 

Subscribe (RSS)

Recent Comments

Sponsored By

What Others Are Saying