I need more Coffee Spam
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?

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?
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.
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.
?
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!
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
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!