Yep,
That is exactly what is happening. I thought it strange also.
The exact function that I use is below still with the debug echo statements. Everything is how it should be from the echos so the only place I can figure that is coming from is the str_replace() call.
$msgbody is a string and memrow is a db row obtained from mysql_fetch_object().
function prepareMsg( $msgbody, $memrow )
{
$weblink = "";
$prepStr = "";
echo "In prepareMsg<br>";
$prepStr = str_replace( '<<MFNAME>>', $memrow->fname, $msgbody );
$prepStr = str_replace( '<<MLNAME>>', $memrow->lname, $prepStr );
$prepStr = str_replace( '<<MPHONE>>', $memrow->phone, $prepStr );
$prepStr = str_replace( '<<MEMAIL>>', $memrow->email, $prepStr );
echo "memrowurl = " . $memrow->url . "<br>";
if ( strlen( $memrow->url ) == 0 )
{
$weblink = "http://www.mysite.com/welcome.html?uid=$memrow->username";
echo "strlen(memrow) = 0 : weblink = " . $weblink . "<br>";
}
else
{
$weblink = $memrow->url;
echo "strlen(memrow) > 0 ) : weblink = " . $weblink . "<br>";
}
$prepStr = str_replace( '<<WEBLINK>>', $weblink, $prepStr );
echo "prepstr = " . $prepStr . "<br>";
return $prepStr;
}
In every case $weblink is correct but the echo of $prepStr has the incorrect url. Like I said, this only happens if the $weblink is invalid or does not have the http:// with it. The other instance I got it was when $weblink = 'http;//...' notice the semi-colon instead of colon.
Thanks,
Greg