我正在尝试从数据库中获取用户名列表,以查看消息是否包含@username,现在我有以下代码:
if (strpos($data[3], '@') !== false) {
$user_array_thing = array();
$user_query = mysql_query("SELECT username FROM users");
while($user_username = mysql_fetch_array($user_query) && in_array($data[4],$user_array_thing) === false){
if(strpos($data[3],'@'.$user_username['username']) !== false){
//echo a message to somebody
echo '<li class="qn"><a href="/status/index.php?user='.$prof_user.'&status='.$data[4].'" class="qn_vis"><font color="#007a00"><b><< '.$data[2].':</b> '.$data[3].'</font> - <font size="1" color="#a3a3a3">'.Timesince(strtotime($time)).' ago</font></a></a><!--<div id="delete'.$data[4].'" style="display:none; margin:0px;" class="qn_div"><form method="post" action=""><input type="hidden" name="messageid" id="messageid" value="'.$data[4].'" /><input class="button small red" type="submit" id="delete" name="delete" value="Delete" /></form><br></div>-->';
$user_array_thing[] = $data[4];
}
}
} else {
$data[3] = preg_replace('|\B#([\d\w_]+)|i', '<font color="#8020E0">$0</font>', $data[3]);
$data[3] = preg_replace('|\B\@([\d\w_]+)|i', '<font color="#1378E0">$0</font>', $data[3]);
echo '<li class="qn"><a href="/status/index.php?user='.$prof_user.'&status='.$data[4].'" class="qn_vis"><img src="/images/icons/web/Bubble3.png" /><font color="#147CE6"><b>'.$data[2].' said</font>:</b> '.$data[3].'<font size="1" color="#a3a3a3"> - '.$commentcount.''.Timesince(strtotime($time)).' ago</font></a></a>';
}
它可以完美运行,直到您发布带有电子邮件地址的内容,例如“someone@gmail.com”
gmail.com 不在数据库中,但仍然变绿。我不确定我做错了什么,我已经尝试了几天来解决这个问题,但无济于事。任何建议都会很好