Before you ask, the code belo works. So then you ask, why am I posting. Well, the code is doing what It should be doing, but not what I want it to. The code uses a regular expression to find where a user has entered a term that appears in a table in a database, and replaces it with a link to this page except $page will get the row corresponding to that term. It works, but For some terms it adds () after them like and. And sometimes it ignores the term altogether. This only seems to happen when I enter a new term though. Any help please?
<?php
if (!$page) {
$page = 'flash mx';
}
?>
<html><head><title>Flashsoup - <?php echo($page); ?></title></head>
<script>
function winClose() {
window.close();
}
</script>
<link rel="StyleSheet" type="text/css" href="../css/style.css">
<body bgcolor=#cccccc>
<?php
$conn = @mysql_connect("localhost","","");
$db = @mysql_select_db("users", $conn);
$sql = "select property,info,type from terms WHERE property=\"$page\" ";
$qr = mysql_query($sql,$conn);
while( $row = mysql_fetch_array($qr) ) {
$info = $row["info"];
if($row["type"] == "as" ) {
$msg.= " <img src=\"images/ascript.gif\"> ";
}
elseif($row["type"] == "gf" ) {
$msg.= " <img src=\"images/flash.gif\"> ";
}
elseif($row["type"] == "bt" ) {
$msg.= " <img src=\"images/cog.gif\"> ";
}
$msg.= "<b>".$row["property"]."</b> - ";
}
$sql = "select property from terms";
$qr = mysql_query($sql, $conn) or die("qr:Bleh");
while( $ptr = mysql_fetch_array($qr) ) {
$prop = $ptr["property"];
$info = ereg_replace($prop.' ','<a href="popup.php?mode=viewterm&page='.$prop.'"><font class=err> '.$prop.' </font></a>',$info);
}
echo($msg);
echo($info);
?><p>
<a href="javascript:winClose()">Close</a>
</body></html>