Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking if a string contains a username from a database to make a message green
    primarykey
    data
    text
    <p>I am trying to get a list of username from a database to see if a message contains @username, and right now I have this code:</p> <pre><code>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) &amp;&amp; in_array($data[4],$user_array_thing) === false){ if(strpos($data[3],'@'.$user_username['username']) !== false){ //echo a message to somebody echo '&lt;li class="qn"&gt;&lt;a href="/status/index.php?user='.$prof_user.'&amp;status='.$data[4].'" class="qn_vis"&gt;&lt;font color="#007a00"&gt;&lt;b&gt;&lt;&lt; '.$data[2].':&lt;/b&gt;&amp;nbsp;&amp;nbsp;'.$data[3].'&lt;/font&gt; - &lt;font size="1" color="#a3a3a3"&gt;'.Timesince(strtotime($time)).' ago&lt;/font&gt;&lt;/a&gt;&lt;/a&gt;&lt;!--&lt;div id="delete'.$data[4].'" style="display:none; margin:0px;" class="qn_div"&gt;&lt;form method="post" action=""&gt;&lt;input type="hidden" name="messageid" id="messageid" value="'.$data[4].'" /&gt;&lt;input class="button small red" type="submit" id="delete" name="delete" value="Delete" /&gt;&lt;/form&gt;&lt;br&gt;&lt;/div&gt;--&gt;'; $user_array_thing[] = $data[4]; } } } else { $data[3] = preg_replace('|\B#([\d\w_]+)|i', '&lt;font color="#8020E0"&gt;$0&lt;/font&gt;', $data[3]); $data[3] = preg_replace('|\B\@([\d\w_]+)|i', '&lt;font color="#1378E0"&gt;$0&lt;/font&gt;', $data[3]); echo '&lt;li class="qn"&gt;&lt;a href="/status/index.php?user='.$prof_user.'&amp;status='.$data[4].'" class="qn_vis"&gt;&lt;img src="/images/icons/web/Bubble3.png" /&gt;&lt;font color="#147CE6"&gt;&lt;b&gt;'.$data[2].' said&lt;/font&gt;:&lt;/b&gt;&amp;nbsp;&amp;nbsp;'.$data[3].'&lt;font size="1" color="#a3a3a3"&gt; - '.$commentcount.''.Timesince(strtotime($time)).' ago&lt;/font&gt;&lt;/a&gt;&lt;/a&gt;'; } </code></pre> <p>It works perfectly, until you post something with an e-mail address in it, like 'someone@gmail.com'</p> <p>gmail.com is not in the database, but is still turning green. I'm not sure what I've done wrong, I've been trying to fix this for days now, to no avail. Any suggestions would be nice</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload