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
Share on other sites

I'm guessing something is wrong with your query. I would try changing the line with a query to:

$FIND = mysql_query("SELECT * FROM userdata WHERE uename != '0'") or die( echo "Mysql Error: ".mysql_error() );

 

Link to comment
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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.