Jump to content

"strstr(): Empty delimiter" issue


andyhajime

Recommended Posts

Hi all,

 

 

What the coding does is suppose to do is run a sql_query on the database, fetch the id of the names in the $TEXT (if exist) and replace it with the <a> tag linking to their profile... but I couldn't quit understand why I keep receiving an "strstr(): Empty delimiter".

 

Please help.

 

$TEXT = "There you see andy walks on the road to that azy house";

$FIND = mysql_query("SELECT * FROM userdata WHERE uename != '0'");
while($FOUND = mysql_fetch_array($FIND))
{

$UENAME = $FOUND['uename'];   // note: first result is 'andy' (id: 1) followed by 'misa' (id: 2) then 'azy' (id: 3)

if(strstr($TEXT, $UENAME)) //<--- ERROR: Warning: strstr() [function.strstr]: Empty delimiter in /home/public_html/ajax.php on line 59
{
	$TAGNAME = ' <a href="profile.php?id='.$FOUND['id'].'">' . $UENAME . '</a> ';
	$TEXT = str_replace($UENAME, $TAGNAME, $TEXT);
}
else
{
	// do nothing
}
}

// result: There you see <a href="profile.php?id=1">andy</a> walks on the road to that <a href="profile.php?id=3">azy</a> house

Link to comment
https://forums.phpfreaks.com/topic/203282-strstr-empty-delimiter-issue/
Share on other sites

Guys, I've just find out the problem.

Apparently one of the 'uename' in the database is EMPTY/Blank.

When I've replace the 0 with nothing, then it works. It's no wonder it say "Empty delimiter" in strstr, the strsrt is getting an 'empty' value. lols

 

$FIND = mysql_query("SELECT * FROM userdata WHERE uename != ''")

 

 

ZachMEdwards:

Thanks man... the 'do nothing' part is normally there for checking only like the sample below. I usually don't use the 'do nothing' method unless I encounter errors it the code. But thanks yeah for responding. Appreciate it.  ;D

 

if(strstr($email, "@"))
{
echo 'found';
//...and do something
}
else
{
echo 'not found';
// do nothing
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.