01.
<?php
02.
$host
=
"localhost"
;
03.
$username
=
""
;
04.
$password
=
""
;
05.
$db
=
"mydatabase"
;
06.
$tb
=
"rude"
;
07.
mysql_connect(
$host
,
$username
,
$password
)
or
die
(
"ติดต่อกับฐานข้อมูล Mysql ไม่ได้ "
);
08.
mysql_select_db(
$db
)
or
die
(
"เลือกฐานข้อมูลไม่ได้"
);
09.
10.
function
CheckRude(
$temp
){
11.
12.
13.
$wordchange
= (
"<font color=red>*</font>"
) ;
14.
15.
$sql
=
"select * from rude"
;
16.
$dbquery
= mysql_query(
$sql
);
17.
$num_rows
= mysql_num_rows(
$dbquery
);
18.
19.
$i
=0;
20.
while
(
$i
<
$num_rows
)
21.
{
22.
$result
= mysql_fetch_array(
$dbquery
);
23.
$temp
=
eregi_replace
(
"$result[rude_name]"
,
$wordchange
,
$temp
);
24.
$i
++;
25.
}
26.
27.
return
(
$temp
) ;
28.
}
29.
30.
$msg
=
"พวกมึงเป็นยังไงบ้าง กูสบายดีนะ มึงสบายดีไหม"
;
31.
32.
$msg_new
=CheckRude(
$msg
);
33.
34.
echo
$msg_new
;
35.
?>