I'm writing a mysql/php form, here's my page called functions.php, which is required in every page... anyways, i'm trying to install an emoticon system, and have the fallowing code,
-----------------------------------------------------------
Does anyone know how to sucessfully merge the lines... i'm not exactly sure where to put the first code box,
any and all help would be greatly appreciated, Thank you for your help
PHP Code:
<?
if (isset($_POST['message'])) { $post = $_POST['message']; }
$post = htmlspecialchars(trim(stripslashes($post)));
$post = str_replace(":)", "<img src='images/icon_01.gif'>", $post);
$post = str_replace(":d", "<img src='images/icon_02.gif'>", $post);
$post = str_replace(":(", "<img src='images/icon_03.gif'>", $post);
$post = str_replace(":x", "<img src='images/icon_04.gif'>", $post);
$post = str_replace(":o", "<img src='images/icon_05.gif'>", $post);
$post = str_replace(":p", "<img src='images/icon_06.gif'>", $post);
$post = str_replace(":?", "<img src='images/icon_07.gif'>", $post);
$post = nl2br($post);
echo "Output: <br>". $post;
?>
PHP Code:
<?php
include "config.php";
mysql_connect("$dbhost","$dbuser","$dbpasswd");
mysql_select_db("$dbname");
function viewpost ($topicID) {
$topic_query = mysql_query("SELECT TopicName FROM topics WHERE (ID=$topicID)");
$topic = mysql_fetch_array($topic_query);
?>
<table cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td class="location" width="50%"><a href="../"></a> » <a href="./">Forums</a> » <a href="view.php?topicID=<?php echo $topicID ?>"><?php echo $topic['TopicName'] ?></a></td>
<td class="postbuttons" width="50%"><a href="add-post.php?topicID=<?php echo $topicID ?>">Post Reply</a></td>
</tr>
<tr>
<td colspan="2" height="5"></td>
</tr>
</table>
<p>
<table border="0" cellpadding="0" cellspacing="1" width="100%" bgcolor="000000">
<tr align="left" valign="top">
<td width="100%">
<table border="0" bgcolor="#000000" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td colspan="3" bgcolor="#ffffff" width="100%">
<table class="cat_header" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td>
<p><b><font class="font2">
<a href="view.php?topicID=<?php echo $topicID ?>"><?php echo $topic['TopicName'] ?></a>
</font></b></p>
</td>
</tr>
</table>
</td>
</tr>
<?php
$post_query = mysql_query("SELECT * FROM posts WHERE (TopicID='$topicID') ORDER BY TimeStamp");
while ($post = mysql_fetch_array($post_query)) {
?>
<tr>
<td valign="top" width="82%" bgcolor="#eeeeee">
<br>
<table align="center" cellpadding="0" cellspacing="0" width="90%" height="90%" class="thread_message">
<tr>
<td width="40" height="30" class="thread_tl"></td>
<td height="30" class="thread_t"></td>
<td width="40" height="30" class="thread_tr"></td>
</tr>
<tr>
<td width="40" class="thread_l"></td>
<td>
<font class="font1">
<?php
echo $post['Post'];
?>
<center><hr width="100%" color="#aaaaaa" size="1"></center>
</font>
</td>
<td align="right" width="40" class="thread_r"></td>
</tr>
<tr>
<td width="40" height="50" class="thread_bl"></td>
<td height="50" class="thread_b">
<a href="edit-post.php?postID=<?php echo $post['ID'] ?>"><img src="./images/format_icon_edit.gif" alt="edit" border="0"></a>
<a href="delete-post.php?postID=<?php echo $post['ID'] ?>"><img src="./images/format_icon_delete.gif" alt="delete" border="0"></a>
</td>
<td width="40" height="50" class="thread_br"></td>
</tr>
</table>
</td>
<td align="center" valign="center" width="18%" bgcolor="#eeeeee">
<font class="font2">
<b><a href="mailto:<?php echo $post['Email'] ?>" border="0"><?php echo $post['Name'] ?></a></b><br>
<img>
</font>
</td>
</tr>
<tr>
<td bgcolor="#eeeeee" colspan="2">
<hr width="100%" color="#aaaaaa" size="1">
</td>
</tr>
<?php
}
if (mysql_num_rows($post_query) < 1) {
?>
<tr>
<td align="center" valign="center" width="100%" bgcolor="#eeeeee" colspan="2">
<font class="font2"><b>
There are currently no posts currently in this topic
</b></font>
</td>
</tr>
<?php } ?>
<tr>
<td colspan="3" bgcolor="#c0c0c0" width="100%">
<table class="cat_header" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td>
<p><b><font class="font2"> </font></b></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
function MakeTableLogins($dbname, $dbhost, $dbuser, $dbpasswd) {//create the logins table
$linkID = mysql_connect($dbhost, $dbuser, $dbpasswd);
mysql_select_db($dbname, $linkID);
mysql_query("create table logins (user char(32), pasword char(32))", $linkID);
}
function Encrypt($string) {//hash then encrypt a string
$crypted = crypt(md5($string), md5($string));
return $crypted;
}
function AddUser($dbname, $dbhost, $dbuser, $dbpass, $username, $password) { //add user to table logins
$linkID = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $linkID);
$password = encrypt($password);
$username = encrypt($username);
mysql_query("insert into logins values ('$username', '$password')", $linkID);
}
function Login($dbname, $dbhost, $dbuser, $dbpass, $user, $password) { //attempt to login false if invalid true if correct
$auth = false;
$user = Encrypt($user);
$linkID = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db("$dbname", $linkID);
$result = mysql_query("select password from logins where user = '$user'", $linkID);
$pass = mysql_fetch_row($result);
mysql_close($linkID);
if ($pass[0] === (Encrypt($password))) {
$auth = true;
}
return $auth;
}
?>
<?php
}
function addpost () {
global $password,$email,$name,$post,$topicID;
$timestamp = time();
$new_password = addslashes($password); $new_email = addslashes($email);
$new_name = addslashes($name);
$new_post = addslashes(nl2br(htmlspecialchars($post)));
$insert = mysql_query("INSERT INTO posts VALUES ('NULL','$topicID','$new_name','$new_email','$new_password','$timestamp','$new_post')");
if (mysql_error() != "") {
?>
<br><p><center><b>There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
exit;
}
}
function editpost () {
global $postID,$post;
$new_post = addslashes(nl2br(htmlspecialchars($post)));
$insert = mysql_query("UPDATE posts SET post='$new_post' WHERE (ID='$postID')");
if (mysql_error() != "") {
?>
<br><p><center><b><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
exit;
}
}
function deletepost () {
global $postID;
$post_query = mysql_query("DELETE FROM posts WHERE (ID='$postID')");
if (mysql_error() != "") {
?>
<br><p><center><b><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
exit;
}
}
function addtopic () {
global $topicname;
$new_topicname = addslashes($topicname);
$topic_query = mysql_query("INSERT INTO topics VALUES ('NULL','$new_topicname')");
if (mysql_error() != "") {
?>
<br><p><center><b><FONT SIZE="-1" FACE="Trebuchet MS,Arial,Helvetica">There was a MySQL Error -- <?php echo mysql_error() ?></b></center></p>
<?php
exit;
}
return mysql_insert_id();
}
?>
Does anyone know how to sucessfully merge the lines... i'm not exactly sure where to put the first code box,
any and all help would be greatly appreciated, Thank you for your help
Comment