I have problem with php’s preg_match.I want to make something like this :
When someone on forum post someones username (example: @Username text..) to do the mysql query to insert notification to database.
I’ve made this code :
<?php
$this = mysql_query("SELECT id,username FROM users");
while($the = mysql_fetch_array($this)){
if(preg_match("/^@".$the['username']."/",$form_text)){
mysql_query("INSERT INTO notifications (num,who) VALUES ('$forum_id','".$the['username']."')");
}
?>
But something is not working.How can i fix it ?
Thanks.
Try and use:
Hope this helps.
Edit: You should also protect yourself from SQL injections, lookup this page:
http://php.net/manual/en/security.database.sql-injection.php