Page 1 of 1

Last question ....How do i make JUST commenting??

Posted: Sun Apr 08, 2012 4:12 pm
by jaysus7
how do i make commenting on a users page with out using a blog post ?

memer page
<?php

include ("coreblog/initblog.php");
include('core/init.inc.php');

if (isset($_GET['pid'], $_POST['user'], $_POST['body'])){
	if (add_comment($_GET['pid'], $_POST['user'], $_POST['body'])){
		header("Location: blog_read.php?pid={$_GET['pid']}");
	}else{
		header('Location: blog_list.php');
	}
	die();
}

$user_info = fetch_user_info($_GET['uid']);

?>

 <form action="" method="post">
  <h2> </h2>
  <div>
  <h2>Sandpile:<br />
<h4>By <?php echo $post['user']; ?> on <?php echo $post['date']; ?></h4>
    <h4>(<?php echo $post['total_comment'];?>comments, last comment <?php echo $post['last_comment']; ?>)</h4>
    
    <hr />
    
    <p><?php $post['preview']; ?></p>
    
</div>
<form>
  <table width="100%">
    <tr>
      <td width="10%"> </td>
      <td width="18%"><label for="user">Name</label></td>
      <td width="45%"><input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" /></td>
      <td width="11%"> </td>
      <td width="16%"> </td>
    </tr>
    <tr>
      <td> </td>
      <td>Title</td>
      <td><input type="text" name="title" id="title" /></td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td><textarea name="body" rows="20" cols="60"></textarea></td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td><input type="submit" value="Add Comment" /></td>
      <td> </td>
    </tr>
  </table>
  <div><?php 

	}
	
	?>
    </form>

Re: Last question ....How do i make JUST commenting??

Posted: Sun Apr 08, 2012 4:53 pm
by SkillBuzz
You mean like a "Wall"?

Pretty much the same as the blog/comment, except you turn the profile pages into the "blogs" themselves.

Re: Last question ....How do i make JUST commenting??

Posted: Wed Apr 18, 2012 4:30 pm
by jaysus7
ya exactly like a wall....but i need to know where to start off would i change all my code to 'uid' and $user instead of pid and $post
and all i want is commenting like the wall to show up on everyones pad so if i visit billy i can see his wall if i visit jnnifer i only see her wall

Re: Last question ....How do i make JUST commenting??

Posted: Wed Apr 18, 2012 9:15 pm
by Temor
It's really just a matter of moving the commenting form from a blog page to a user page. You will use the exact same functions. Instead of looking for a blog id or a post id to go along with the comment, you'll check for the user id.

Don't make it harder for you than it already is :) Recycle your code.

Re: Last question ....How do i make JUST commenting??

Posted: Thu Apr 19, 2012 5:13 am
by jaysus7
invalid id???? is this the right track???

wall
<?php

include ("coreblog/initblog.php");
include('core/init.inc.php');

$user_info = fetch_user_info($_GET['uid']);

if (isset($_GET['uid'], $_POST['user'], $_POST['body'])){
	if (add_comment($_GET['uid'], $_POST['user'], $_POST['body'])){
		header("Location: member1.php?uid={$_GET['uid']}");
	}else{
		header('Location: member1.php?uid={uid}');
	}
	die();
}

?>
       <?php

if (isset($_GET['uid']) === false || valid_pid($_GET['uid']) === false){
	echo 'Invalid post ID.';
}else{
	$post = get_post($_GET['pid'])

	?>
<h2><?php echo $post['title']; ?></h2>
    <h3>By: <?php echo $post['user']; ?> on: <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h3>
    
    <hr />
    
    <p><?php echo $post['body']; ?></p>
    
    <hr />
    <?php
	
	foreach ($post['comments'] as $comment){
		?>
    
	 <h3>By: <?php echo $comment['body']; ?> on <?php echo $comment['date']; ?></h3>
     <p><?php echo $comment['user']; ?></p>
     <hr />
     <?php
	}

	?>
<form action="" method="post">
<p>
	<label for="user">Name</label>
    <input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" />
</p>
<p>
	<textarea name="body" rows="20" cols="60"></textarea>
</p>
<p>
	<input type="submit" value="Add Comment" />
</p>
</form>    
<?php

}

?>

Comments 2

<?php

//fetches all the comments for a given blog post
function get_comments($uid){
	$uid = (int)$uid;
	
	$sql = "SELECT
				`comment_body` AS `body`,
				`comment_user` AS `user`,
				DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
			FROM `comments`
			WHERE `user_id` = {$uid}";
	
	$comments = mysql_query($sql);
	echo mysql_error();
	$return = array();
	while (($row = mysql_fetch_assoc($comments)) !== false){
		$return[] = $row;
	}
		return $return;
}

//add a comment
function add_comment($uid, $user, $body){
	if (valid_pid($uid) === false){
		return false;
	}
	
	$uid	= (int)$uid;
	$user	= mysql_real_escape_string(htmlentities($user));
	$body	= mysql_real_escape_string(nl2br(htmlentities($body)));
	
	mysql_query("INSERT INTO `comments` (`user_id`, `comment_body`, `comment_user`, `comment_date`) VALUES ({$uid}, '{$user}', '{$body}', NOW())");
echo mysql_error();
	return true;
	
}

?>

Re: Last question ....How do i make JUST commenting??

Posted: Thu Apr 19, 2012 5:44 pm
by Temor
what is the code for the valid_pid function?

Essentially, all you have to do to create this is instead of printing out a post on your blog page, you print out user information. You know how to fetch a users information based on his id, and you know how to add comments to a page. You're really doing the exact same thing as in the blog tutorial except you fetch user information based on id instead of a blog post based on id.

Re: Last question ....How do i make JUST commenting??

Posted: Wed Apr 25, 2012 1:41 am
by jaysus7
Comments back file
 <?php
error_reporting(E_ALL);
//checks if the given user id is in the table
function valid_uid($uid){
        $uid = (int)$uid;
       
        $total = mysql_query("SELECT COUNT(`comment_id`) FROM `comments` WHERE `user_id` = {$uid}");
        $total = mysql_result($total, 0);
 
        if ($total != 1){
                return false;
        }else{
                return true;
        }
}

//fetches all the comments for a given blog post
function get_comments($uid){
	$uid = (int)$uid;
	
	$sql = "SELECT
				`comment_body` AS `body`,
				`comment_user` AS `user`,
				DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
			FROM `comments`
			WHERE `user_id` = {$uid}";
	
	$comments = mysql_query($sql);
	echo mysql_error();
	$return = array();
	while (($row = mysql_fetch_assoc($comments)) !== false){
		$return[] = $row;
	}
		return $return;
}

//add a comment
function add_comment($uid, $user, $body){
	if (valid_pid($uid) === false){
		return false;
	}
	
	$uid	= (int)$uid;
	$user	= mysql_real_escape_string(htmlentities($user));
	$body	= mysql_real_escape_string(nl2br(htmlentities($body)));
	
	mysql_query("INSERT INTO `comments` (`user_id`, `comment_body`, `comment_user`, `comment_date`) VALUES ('{$uid}', '{$user}', '{$body}', NOW())");
echo mysql_error();
	return true;
	
}

?>


Members page


 <?php
error_reporting(E_ALL);
include ("coreblog/initblog.php");
include('core/init.inc.php');

$user_info = fetch_user_info($_GET['uid']);

if (isset($_GET['uid'], $_POST['user'], $_POST['body'])){
	if (add_comment($_GET['uid'], $_POST['user'], $_POST['body'])){
		header("Location: member1.php?uid={$_GET['uid']}");
	}else{
		header('Location: member1.php');
	}
	die();
} 

?> <?php

if (isset($_GET['uid']) === false || valid_pid($_GET['uid']) === false){
	echo 'Invalid post ID.';
}else{
	$post = get_comments($_GET['uid'])

	?>
<h2><?php echo $post['title']; ?></h2>
    <h3>By: <?php echo $post['user']; ?> on: <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h3>
    
    <hr />
    
    <p><?php echo $post['body']; ?></p>
    
    <hr />
    <?php
	
	foreach ($post['comments'] as $comment){
		?>
    
	 <h3>By: <?php echo $comment['body']; ?> on <?php echo $comment['date']; ?></h3>
     <p><?php echo $comment['user']; ?></p>
     <hr />
     <?php
	}

	?>
<form action="" method="post">
<p>
	<label for="user">Name</label>
    <input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" />
</p>
<p>
	<textarea name="body" rows="20" cols="60"></textarea>
</p>
<p>
	<input type="submit" value="Add Comment" />
</p>
</form>    
<?php

}

?>

Re: Last question ....How do i make JUST commenting??

Posted: Fri Apr 27, 2012 12:38 pm
by Temor
Is it working?
if (isset($_GET['uid']) === false || valid_pid($_GET['uid']) === false){
You might want to change valid_pid to valid_uid seeing as you're not on a post page, but a user page.

Here too:
function add_comment($uid, $user, $body){
        if (valid_pid($uid) === false){
                return false;
        }
       

Re: Last question ....How do i make JUST commenting??

Posted: Fri Apr 27, 2012 4:59 pm
by jaysus7
oops i did that all ready forgot to post that...did it last night...but still nothing....no errors and no results???

Fatal error: Call to undefined function valid_uid() in /home/content/50/8811650/html/member1.php on line 297

is the error i get


comments back file
<?php
error_reporting(E_ALL);
//checks if the given user id is in the table
function valid_uid($uid){
        $uid = (int)$uid;
       
        $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_id` = {$uid}");
        $total = mysql_result($total, 0);
 
        if ($total != 1){
                return false;
        }else{
                return true;
        }
}

//fetches all the comments for a given blog post
function get_comments($uid){
	$uid = (int)$uid;
	
	$sql = "SELECT
				`comment_body` AS `body`,
				`comment_user` AS `user`,
				DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
			FROM `comments`
			WHERE `user_id` = {$uid}";
	
	$comments = mysql_query($sql);
	echo mysql_error();
	$return = array();
	while (($row = mysql_fetch_assoc($comments)) !== false){
		$return[] = $row;
	}
		return $return;
}

//add a comment
function add_comment($uid, $user, $body){
	if (valid_uid($uid) === false){
		return false;
	}
	
	$uid	= (int)$uid;
	$user	= mysql_real_escape_string(htmlentities($user));
	$body	= mysql_real_escape_string(nl2br(htmlentities($body)));
	
	mysql_query("INSERT INTO `comments` (`user_id`, `comment_body`, `comment_user`, `comment_date`) VALUES ('{$uid}', '{$user}', '{$body}', NOW())");
echo mysql_error();
	return true;
	
}

?>

member page
<?php
error_reporting(E_ALL);
include ("coreblog/initblog.php");
include('core/init.inc.php');

$user_info = fetch_user_info($_GET['uid']);

if (isset($_GET['uid'], $_POST['user'], $_POST['body'])){
	if (add_comment($_GET['uid'], $_POST['user'], $_POST['body'])){
		header("Location: member1.php?uid={$_GET['uid']}");
	}else{
		header('Location: member1.php');
	}
	die();
} 

?>
 <?php

if (isset($_GET['uid']) === false || valid_uid($_GET['uid']) === false){
	echo 'Invalid username.';
}else{
	$post = get_comments($_GET['uid'])

	?>
<h2><?php echo $post['title']; ?></h2>
    <h3>By: <?php echo $post['user']; ?> on: <?php echo $post['date']; ?> (<?php echo count($post['comments']); ?> comments)</h3>
    
    <hr />
    
    <p><?php echo $post['body']; ?></p>
    
    <hr />
    <?php
	
	foreach ($post['comments'] as $comment){
		?>
    
	 <h3>By: <?php echo $comment['body']; ?> on <?php echo $comment['date']; ?></h3>
     <p><?php echo $comment['user']; ?></p>
     <hr />
     <?php
	}

	?>
<form action="" method="post">
<p>
	<label for="user">Name</label>
    <input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" />
</p>
<p>
	<textarea name="body" rows="20" cols="60"></textarea>
</p>
<p>
	<input type="submit" value="Add Comment" />
</p>
</form>    
<?php

}

?>

Re: Last question ....How do i make JUST commenting??

Posted: Sat Apr 28, 2012 12:48 pm
by Temor
Line 297?

I can't tell you what's wrong if I can't see all your code, and apparently over 230 lines are missing.

Re: Last question ....How do i make JUST commenting??

Posted: Sun Apr 29, 2012 6:15 pm
by jaysus7
its all just html code...i just sent you the php code...but i will send the entire thing later when i am off work...thank you !!

Re: Last question ....How do i make JUST commenting??

Posted: Mon Apr 30, 2012 2:37 am
by jaysus7
i get this error message....
Notice: Undefined index: comments in /home/content/50/8811650/html/member1.php on line 305

Warning: Invalid argument supplied for foreach() in /home/content/50/8811650/html/member1.php on line 305


it adds a comment to the database, however it doesn't show on the users page??


member page
<?php
error_reporting(E_ALL);
include ("coreblog/initblog.php");
include('core/init.inc.php');

$user_info = fetch_user_info($_GET['uid']);

if (isset($_GET['uid'], $_POST['user'], $_POST['body'])){
	if (add_wall_comment($_GET['uid'], $_POST['user'], $_POST['body'])){
		header("Location: member1.php?uid={$_GET['uid']}");
	}else{
		header('Location: member1.php');
	}
	die();
} 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $user_info['username']; ?>'s Portfolio - Know Quest</title>
<style type="text/css">
<!--
body {
	font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
	background: #42413C;
	margin: 0;
	padding: 0;
	color: #000;
	background-color: #FFFFFF;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
	padding: 0;
	margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
	margin-top: 0;	 /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
	padding-right: 15px;
	padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
	text-align: left;
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
	border: none;
}

/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
	color: #C4B43C;
	text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
	color: #C4B43C;
	text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
	text-decoration: none;
}

/* ~~this fixed width container surrounds the other divs~~ */
.container {
	width: 1200px;
	background: #FFF;
	margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
}

/* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
.header {
	background: #1D3164;
	width: 1200px;
}

/* ~~ These are the columns for the layout. ~~ 

1) Padding is only placed on the top and/or bottom of the divs. The elements within these divs have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.

2) No margin has been given to the columns since they are all floated. If you must add margin, avoid placing it on the side you're floating toward (for example: a right margin on a div set to float right). Many times, padding can be used instead. For divs where this rule must be broken, you should add a "display:inline" declaration to the div's rule to tame a bug where some versions of Internet Explorer double the margin.

3) Since classes can be used multiple times in a document (and an element can also have multiple classes applied), the columns have been assigned class names instead of IDs. For example, two sidebar divs could be stacked if necessary. These can very easily be changed to IDs if that's your preference, as long as you'll only be using them once per document.

4) If you prefer your nav on the right instead of the left, simply float these columns the opposite direction (all right instead of all left) and they'll render in reverse order. There's no need to move the divs around in the HTML source.

*/
.sidebar1 {
	float: left;
	width: 195px;
	background: white;
	padding-bottom: 10px;
	border-right-width: thin;
	border-bottom-color: #000;
}
.content {
	padding: 10px 0;
	width: 1000px;
	float: left;
}

/* ~~ This grouped selector gives the lists in the .content area space ~~ */
.content ul, .content ol { 
	padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */
}

/* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */
ul.nav {
	list-style: none; /* this removes the list marker */
	border-top: 1px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */
	margin-bottom: 15px; /* this creates the space between the navigation on the content below */
}
ul.nav li {
	border-bottom: 1px solid #666; /* this creates the button separation */
}
ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */
	padding: 5px 5px 5px 15px;
	display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */
	width: 160px;  /*this width makes the entire button clickable for IE6. If you don't need to support IE6, it can be removed. Calculate the proper width by subtracting the padding on this link from the width of your sidebar container. */
	text-decoration: none;
	background: #C6D580;
}
ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */
	background: #ADB96E;
	color: #FFF;
}

/* ~~ The footer ~~ */
.footer {
	padding: 10px 0;
	background: #1D3164;
	position: relative;/* this gives IE6 hasLayout to properly clear */
	clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
}

/* ~~ miscellaneous float/clear classes ~~ */
.fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
	float: right;
	margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
	float: left;
	margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
	clear:both;
	height:0;
	font-size: 1px;
	line-height: 0px;
}
h5 {
	color: #FFF;
	font-size: 10pt;
}
h6 {
	color: #090;
}
h4 {
	font-size: 11pt;
	color: #000;
}
h3 {
	font-size: 11pt;
}
h2 {
	font-size: 12pt;
}
body,td,th {
	font-size: 10pt;
}
.container .content form h3 label {
	text-align: center;
}
.container .content form h3 label {
	text-align: center;
}
.container .content form h3 label {
	text-align: center;
}
-->
</style></head>

<body>

<div class="container">
  <div class="header"><!-- end .header -->
    <p> </p>
    <p><img src="Images/Untitled-1.jpg" alt="Logo Web Header" width="537" height="92" align="left" /></p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <h5><b><?php echo $_SESSION['username']; ?></b> <?php echo "<a href='logout.php'>Logout</a>";?> |<a href="Edit.php"> <?php echo "<a href='member1.php?uid={$_SESSION['uid']}'>Your Research</a>"; ?></a> | <a href="Edit.php">Edit  Portfolio</a> |<a href="protected.php"> To Do List</a> | <a href="blog_posts.php">Post Research</a> | <a href="search_posts.php">Viral Search</a> </a>| <a href="prof_finder.php">Prof. Finder </a>| <a href="user_lists.php">User List</a> |<a href="all research.php"> Colaborated Research</a></h5>
  </div>
  <div class="sidebar1">
    <p> </p>
    <p> </p>
    <h3><a href="blog_list.php"><?php echo $_SESSION['username'];?> Research</a></h3>
    <h4>
   <?php

$posts = get_posts();

foreach ($posts as $post){
	
		?>
<h2><a href="blog_read.php?pid=<?php echo $post['id']; ?>"> <?php echo $post['title']; ?></a></h2>
    <h4>By <?php echo $post['user']; ?> on <?php echo $post['date']; ?></h4>
    <h4>(<?php echo $post['total_comments'];?> comments, last comment <?php echo $post['last_comment']; ?>)</h4>
    
    <hr />
    
    <p><?php $post['preview']; ?></p>
    
    <?php
}

?>
    </h4>
    <p> </p>
    <p> </p>
    <p> </p>
    <!-- end .sidebar1 --></div>
  <div class="content">
    <p> </p>
    <table width="93%" cellpadding="10" cellspacing="10">
      <tr>
        <td width="22%" height="172"><h4><strong>Country</strong></h4>
          <p><?php echo $user_info['location']; ?></p>
        <td width="22%"><h4><strong>Institution</strong></h4>
        <p><?php echo $user_info['institution']; ?></p></td>
        <td width="23%"><h4><strong>Articles Published (Reffered)</strong></h4>
        <p><?php echo $user_info['articlespublishedpre']; ?></p></td>
      </tr>
      <tr>
        <td height="151"><h4><strong>Websit</strong><strong>e</strong></h4>
        <p><?php echo $user_info['website']; ?></p></td>
        <td><h4><strong>
          <label for='professionalresearch5'>Research Center</label>
        </strong></h4>
        <p><?php echo $user_info['researchcentre']; ?></p></td>
        <td><h4><strong>Articles Published (Non-Reffered)</strong></h4>
          <p><?php echo $user_info['researchcentre']; ?></p>
        <h4> </h4></td>
      </tr>
      <tr>
        <td height="154"><h4><strong>Email</strong></h4>
        <p><?php echo $user_info['researchcentre']; ?></p></td>
        <td><h4><strong>Department</strong></h4>
        <p><?php echo $user_info['department']; ?></p></td>
        <td><h4><strong>Published Books</strong></h4>
        <p><?php echo $user_info['publishedbooks']; ?></p></td>
      </tr>
      <tr>
        <td><h4><strong>Social Networking</strong></h4>
        <p><?php echo $user_info['socialmedia']; ?></p>          </p></td>
        <td><h4><img src="<?php echo $user_info['avatar']; ?>" alt="Avatar"/></h4></td>
        <td><h4><strong>Published Chapters</strong></h4>
          <p><?php echo $user_info['publishedchapters']; ?></p>
        <h4> </h4></td>
      </tr>
      <tr>
        <td height="162"><h4><strong>Researchers Cited in Your Research</strong></h4>
        <p><?php echo $user_info['researcherscitedinyourresearch']; ?></p></td>
        <td><h4><strong>Memberships</strong></h4>
        <p><?php echo $user_info['memberships']; ?></p></td>
        <td><h4><strong>Research Methodology Perferred</strong></h4>
        <p><?php echo $user_info['researchmethodologyperferred']; ?></p></td>
      </tr>
      <tr>
        <td height="144"><h4><strong>Non-acidemic Influences</strong></h4>
        <p><?php echo $user_info['nonacidemicinfluences']; ?></p>
        <td><h4>Acidemic Influences</h4>
<p><?php echo $user_info['acidemicinfluences']; ?></p></td>
        <td><h4><strong>Confidence Proceedings</strong></h4>
        <p><?php echo $user_info['confidenceproceedings']; ?></p></td>
      </tr>
      <tr>
        <td height="171"><h4><strong>Speciality</strong></h4>
        <p><?php echo $user_info['speciality']; ?></p></td>
        <td><h4><strong>Key Words</strong></h4>
          <p><?php echo $user_info['keywords']; ?>
            </h2>
        </p></td>
        <td><h4><strong>Data Sets</strong></h4>
        <p><?php echo $user_info['datasets']; ?></p></td>
      </tr>
    </table>
    
    <center>
      <p> </p>
      <p> </p>
      <p> </p>
      <hr />
      <p> </p>
        <?php

if (isset($_GET['uid']) === false || valid_uid($_GET['uid']) === false){
	echo 'Invalid username.';
}else{
	$post = get_wall_comments($_GET['uid'])

	?>
    <?php
	
	foreach ($post['comments'] as $comment){
		?>
    
	 <h3>By: <?php echo $comment['body']; ?> on <?php echo $comment['date']; ?></h3>
     <p><?php echo $comment['user']; ?></p>
     <hr />
     <?php
	}

	?>
<form action="" method="post">
<p>
	<label for="user">Name</label>
    <input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" />
</p>
<p>
	<textarea name="body" rows="20" cols="60"></textarea>
</p>
<p>
	<input type="submit" value="Add Comment" />
</p>
</form>    
<?php

}

?>
    <h1> </h1>
  <!-- end .content --></div>
  <div class="footer">
    <form>
      <h5>___________________________________________________________________________________________________________________________________</h5>
      <h5><a href="termsofuse.html">Terms of use</a><b> </b>|<a href="Edit.php"> <?php echo "<a href='member1.php?uid={$_SESSION['uid']}'>Your Research</a>"; ?></a> | <a href="Edit.php">Edit  Portfolio</a> |<a href="protected.php"> To Do List</a> | <a href="blog_posts.php">Post Research</a> | <a href="search_posts.php">Viral Search</a> </a>| <a href="prof_finder.php">Prof. Finder </a>| <a href="user_lists.php">User List</a> |<a href="all research.php"> Colaborated Research</a></h5>
      <h5> </h5>
    </form>
    <h6><center>Powered by: <a href="http://jaysco.ca/">Jaysco</a></center>
    <!-- end .footer --></h6>
  </div>
  <!-- end .container --></div>
</body>
</html>

comments 2
<?php
error_reporting(E_ALL);
//fetches the current logged in users id
function fetch_current_user_id($username){
        $username = mysql_real_escape_string($username);
       
        $sql = "SELECT `user_id` FROM `users` WHERE `user_username` = '{$username}'";
        $result = mysql_query($sql);
       
        return mysql_result($result, 0);
}
 


//check if given username exsists in the database
function user_exists($user){
	$user = mysql_real_escape_string($user);
	
	$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_username` = '{$user}'");
	echo mysql_error();
	return (mysql_result($total, 0) == '1') ? true : false;

}
//check if the given username and password combinations are valid
function valid_credentials($user, $pass){
	$user = mysql_real_escape_string($user);
	$pass = mysql_real_escape_string($pass);
	
	$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_username` = '{$user}' AND `user_password` = '{$pass}'");
	
	return (mysql_result($total, 0) == '1') ? true : false;
	
}
//checks to see is user account is active
	function is_active($user){
		$user = mysql_real_escape_string($user);
		echo mysql_error();
		$sql = "SELECT
					COUNT(`activations`.`user_id`)
				FROM `users`
				INNER JOIN `activations`
				ON `users`.`user_id` = `activations`.`user_id`
				WHERE `users`.`user_username` = '{$user}'";
				
	$result = mysql_query($sql);
	echo mysql_error();
	return (mysql_result($result, 0) == '0') ? true : false;
		
}
//acctivates the account related to the given activation code
function activate_account($aid){
	$aid = mysql_real_escape_string($aid);
	
	mysql_query("DELETE FROM `activations` WHERE `activation_code` = '{$aid}'");
echo mysql_error();
}

//adds a user to the database
function add_user($user, $email, $pass, $first, $last){
	$user		= mysql_real_escape_string(htmlentities($user));
	$email		= mysql_real_escape_string($email);
	$pass		= sha1($pass);
	$first		= mysql_real_escape_string(htmlentities($first));
	$last		= mysql_real_escape_string(htmlentities($last));
	
	$charset = array_flip(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')));
	$aid =implode('', array_rand($charset, 10)); 
	
	$body =	<<<EMAIL
	
	Thank you for signing up with knowquest. To activate your account, please click the link below:
	
	http://www.jasonmassieportfolio.com/act ... ?aid={$aid}
	
EMAIL;
	
	mail($email, 'Your new account at Knowquest.com', $body, 'From: admin@knowquest.com');
	
	mysql_query("INSERT INTO `users` (`user_username`, `user_email`, `user_password`,`user_firstname`,`user_lastname`) VALUES ('{$user}', '{$email}', '{$pass}','{$first}','{$last}')");
	echo mysql_error();
	$user_id = mysql_insert_id();
	
	mysql_query("INSERT INTO `activations` (`user_id`, `activation_code`) VALUES ({$user_id}, '{$aid}')");
echo mysql_error();
}

//fetches all of the users from the table
function fetch_users(){
        $result = mysql_query("SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`"); 
        
        $users = array();
       
        while (($row = mysql_fetch_assoc($result)) !== false){
                $users[] = $row;
        }
       
        return $users;
}
 
//fetches profile info for given user
function fetch_user_info($uid){
        $uid = (int)$uid;
       
        $sql = "SELECT
                   `user_id` AS `id`,
                   `user_username` AS `username`,
                   `user_email` AS `email`,
                   `user_firstname` AS `firstname`,
                   `user_lastname` AS `lastname`,
                   `user_institution` AS `institution`,
                   `user_department` AS `department`,
                   `user_location` AS `location`,
                   `user_speciality` AS `speciality`,
                   `user_key words` AS `keywords`,
                   `user_research centre` AS `researchcentre`,
                   `user_website` AS `website`,
				   `user_articles published pre` AS `articlespublishedpre`,
                   `user_articles published non pre` AS `articlespublishednonpre`,
                   `user_published books` AS `publishedbooks`,
                   `user_social media` AS `socialmedia`,
				   `user_published chapters` AS `publishedchapters`,
				   `user_confidence proceedings` AS `confidenceproceedings`,
                   `user_non acidemic influences` AS `nonacidemicinfluences`,
                   `user_data sets` AS `datasets`,
                   `user_research methodology perferred` AS `researchmethodologyperferred`,
                   `user_researchers cited in your research` AS `researcherscitedinyourresearch`,
                   `user_memberships` AS `memberships`,
                   `user_acidemic influences` AS `acidemicinfluences`
                 FROM `users`
                 WHERE `user_id` = {$uid}";
                       
          $result = mysql_query($sql);
            	echo mysql_error();
          $info = mysql_fetch_assoc($result);
                      
          $info['avatar'] = (file_exists("{$GLOBALS['path']}/user_avatars/{$info['id']}.jpg")) ? "core/user_avatars/{$info['id']}.jpg" : "core/user_avatars/default.jpg";
                      
          return $info;
}

//updates current user portfolio info
function set_profile_info($email, $institution, $department, $location, $speciality, $keywords, $researchcentre, $website, $articlespublishedpre, $articlespublishednonpre, $publishedbooks, $socialmedia, $publishedchapters, $confidenceproceedings, $nonacidemicinfluences, $datasets, $researchmethodologyperferred, $researcherscitedinyourresearch, $memberships, $acidemicinfluences, $avatar){
        $email                   	 			= mysql_real_escape_string(htmlentities($email));
		$institution                   			= mysql_real_escape_string(htmlentities($institution));
        $department               				= mysql_real_escape_string(htmlentities($department));
        $location              					= mysql_real_escape_string(htmlentities($location));
        $speciality   							= mysql_real_escape_string(htmlentities($speciality));
        $keywords    							= mysql_real_escape_string(htmlentities($keywords));
        $researchcentre                			= mysql_real_escape_string(htmlentities($researchcentre));
        $website                 				= mysql_real_escape_string(htmlentities($website));
        $articlespublishedpre         		    = mysql_real_escape_string(htmlentities($articlespublishedpre));
		$articlespublishednonpre         		= mysql_real_escape_string(htmlentities($articlespublishednonpre));
        $publishedbooks              			= mysql_real_escape_string(htmlentities($publishedbooks));
		$socialmedia             				= mysql_real_escape_string(htmlentities($socialmedia));
        $publishedchapters                  	= mysql_real_escape_string(htmlentities($publishedchapters));
        $confidenceproceedings                  = mysql_real_escape_string(htmlentities($confidenceproceedings));
		$nonacidemicinfluences        	        = mysql_real_escape_string(htmlentities($nonacidemicinfluences));
        $datasets   							= mysql_real_escape_string(htmlentities($datasets));
        $researchmethodologyperferred    		= mysql_real_escape_string(htmlentities($researchmethodologyperferred));
        $researcherscitedinyourresearch         = mysql_real_escape_string(htmlentities($researcherscitedinyourresearch));
        $memberships                  			= mysql_real_escape_string(htmlentities($memberships));
        $acidemicinfluences              		= mysql_real_escape_string(htmlentities($acidemicinfluences));
     
 		 if (file_exists($avatar)){
                $src_size = getimagesize($avatar);
               			
                if ($src_size['mime'] === 'image/jpeg'){
                    $src_img = imagecreatefromjpeg($avatar);
                }else if ($src_size['mime'] === 'image/png'){
                    $src_img = imagecreatefrompng($avatar);
                }else if ($src_size['mime'] === 'image/gif'){
                    $src_img = imagecreatefromgif($avatar);
                }else{
                 $src_img = false;
                }
                       
                if ($src_img !== false){
                    $thumb_width = 200;
                               
               	    if ($src_size[0] <= $thumb_width){
                        $thumb = $src_img;
					}else{
                         $new_size[0] = $thumb_width;
                         $new_size[1] = ($src_size[1] / $src_size[0]) * $thumb_width;
                                       
                         $thumb = imagecreatetruecolor($new_size[0], $new_size[1]);
                         imagecopyresampled($thumb, $src_img, 0, 0, 0, 0, $new_size[0], $new_size[1], $src_size[0], $src_size[1]);
                    }
					
                    imagejpeg($thumb, "{$GLOBALS['path']}/user_avatars/{$_SESSION['uid']}.jpg");
                
				}
        
		}
       
        $sql = "UPDATE `users` SET
                    `user_email` = '{$email}',
                    `user_institution` = '{$institution}',
                    `user_department` = '{$department}',
                    `user_location` = '{$location}',
                    `user_speciality` = '{$speciality}',
                    `user_key words` = '{$keywords}',
                    `user_research centre` = '{$researchcentre}',
                    `user_website` = '{$website}',
                    `user_articles published pre` = '{$articlespublishedpre}',
					`user_articles published non pre` = '{$articlespublishednonpre}',
                    `user_published books` = '{$publishedbooks}',
                    `user_social media` = '{$socialmedia}',
                    `user_published chapters` = '{$publishedchapters}',
					`user_confidence proceedings` = '{$confidenceproceedings}',
                    `user_non acidemic influences` = '{$nonacidemicinfluences}',
                    `user_data sets` = '{$datasets}',
                    `user_research methodology perferred` = '{$researchmethodologyperferred}',
                    `user_researchers cited in your research` = '{$researcherscitedinyourresearch}',
                    `user_memberships` = '{$memberships}',
					`user_acidemic influences` = '{$acidemicinfluences}'
                WHERE `user_id` = {$_SESSION['uid']}";
              
        mysql_query($sql);
        echo mysql_error();
}

//checks if the given user id is in the table
function valid_uid($uid){
        $uid = (int)$uid;
       
        $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_id` = {$uid}");
        $total = mysql_result($total, 0);
 
        if ($total != 1){
                return false;
        }else{
                return true;
        }
}

//fetches all the comments for a given user wall post
function get_wall_comments($uid){
	$uid = (int)$uid;
	
	$sql = "SELECT
				`comment_body` AS `body`,
				`comment_user` AS `user`,
				DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
			FROM `wallcomments`
			WHERE `user_id` = {$uid}";
	
	$comments = mysql_query($sql);
	
	$return = array();
	while (($row = mysql_fetch_assoc($comments)) !== false){
		$return[] = $row;
	}
		return $return;
}

//add a wall comment
function add_wall_comment($uid, $body, $user){
	if (valid_uid($uid) === false){
		return false;
	}
	
	$uid	= (int)$uid;
	$body	= mysql_real_escape_string(nl2br(htmlentities($body)));
	$user	= mysql_real_escape_string(htmlentities($user));
	
	
	mysql_query("INSERT INTO `wallcomments` (`user_id`, `comment_body`, `comment_user`, `comment_date`) VALUES ('{$uid}', '{$user}', '{$body}', NOW())");
echo mysql_error();
	return true;
	
}

?>

Re: Last question ....How do i make JUST commenting??

Posted: Mon Apr 30, 2012 4:35 pm
by jacek
$post['comments']
is not being defined anywhere.

Re: Last question ....How do i make JUST commenting??

Posted: Mon Apr 30, 2012 5:11 pm
by jaysus7
i have tried uid, user, id, wall comment, comment, comments,

do i have anything that is defined that i can use????

i thought comments was???...obviously not tho.

Re: Last question ....How do i make JUST commenting??

Posted: Tue May 01, 2012 7:14 pm
by jaysus7
last thing i need to be done please help :) I've played around got this its still wrong tho please hemp :)
//checks if the given user id is in the table
function valid_uid($uid){
        $uid = (int)$uid;
       
        $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_id` = {$uid}");
        $total = mysql_result($total, 0);
 
        if ($total != 1){
                return false;
        }else{
                return true;
        }
}

//fetches a single user from the table
function get_user($uid){
        $uid = (int)$uid;
       
        $sql = "SELECT
						`user_id` AS `uid`
                FROM `users`
                WHERE `user_id` = {$uid}";
               
        $post = mysql_query($sql);echo mysql_error();
        $post = mysql_fetch_assoc($post);
       
        $post['comments'] = get_comments($uid);
       
       
        return $post;
}

//fetches all the comments for a given user wall post
function get_wall_comments($uid){
	$uid = (int)$uid;
	
	$sql = "SELECT
				`comment_body` AS `body`,
				`comment_user` AS `user`,
				DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
			FROM `wallcomments`
			WHERE `user_id` = {$uid}";
	
	$comment = mysql_query($sql);
	
	$return = array();
	while (($row = mysql_fetch_assoc($comment)) !== false){
		$return[] = $row;
	}
		return $return;
		
        $comment = mysql_query($sql);
        $comment = mysql_fetch_assoc($comment);
       
        $comment['comment'] = get_wall_comments($comment);
       
       
        return $comment;
}

//add a wall comment
function add_wall_comment($uid, $body, $user){
	if (valid_uid($uid) === false){
		return false;
	}
	
	$uid	= (int)$uid;
	$body	= mysql_real_escape_string(nl2br(htmlentities($body)));
	$user	= mysql_real_escape_string(htmlentities($user));
	
	
	mysql_query("INSERT INTO `wallcomments` (`user_id`, `comment_body`, `comment_user`, `comment_date`) VALUES ('{$uid}', '{$user}', '{$body}', NOW())");

	return true;
	
}



<?php

if (isset($_GET['uid']) === false || valid_uid($_GET['uid']) === false){
	echo 'Be the first to add a comment!';
}else{
	$comment = get_wall_comments($_GET['uid'])

	?>
    <?php
	
	foreach ($comment['comment'] as $comment){
		?>
    
	 <h3>By: <?php echo $comment['body']; ?> on <?php echo $comment['date']; ?></h3>
     <p><?php echo $comment['user']; ?></p>
     <hr />
     <?php
	}

	?>
<form action="" method="post">
<p>
	<label for="user">Name</label>
    <input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" />
</p>
<p>
	<textarea name="body" rows="20" cols="60"></textarea>
</p>
<p>
	<input type="submit" value="Add Comment" />
</p>
</form>    
<?php

}

?>



Re: Last question ....How do i make JUST commenting??

Posted: Thu May 03, 2012 12:15 am
by jacek
//fetches all the comments for a given user wall post
function get_wall_comments($uid){
        $uid = (int)$uid;
       
        $sql = "SELECT
                                `comment_body` AS `body`,
                                `comment_user` AS `user`,
                                DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
                        FROM `wallcomments`
                        WHERE `user_id` = {$uid}";
       
        $comment = mysql_query($sql);
       
        $return = array();
        while (($row = mysql_fetch_assoc($comment)) !== false){
                $return[] = $row;
        }
                return $return;
               
        $comment = mysql_query($sql);
        $comment = mysql_fetch_assoc($comment);
       
        $comment['comment'] = get_wall_comments($comment);
       
       
        return $comment;
}
This function calls itself, obviously you don't want to do that. Your also performing the query twice for now reason.
jaysus7 wrote:i have tried uid, user, id, wall comment, comment, comments,

do i have anything that is defined that i can use????
Really, your trying to guess the variable name that is defined ? You need to defined one so you can call it whatever you like.

I don't think you have any interest in this to be honest, it seems like you have a project that is due in and you are constantly posting to try and get someone to do it for you.

Re: Last question ....How do i make JUST commenting??

Posted: Thu May 03, 2012 4:45 pm
by jaysus7
i do have an interest or i wouldn't have taken on the job i have, i wouldn't have posted on this forum and i wouldn't have tried to trouble shoot on my own lots of errors. i only call upon you guys when i am lost completely lost, so for helping me i thank you...i have a greater knowledge of php now and i appreciate all you guys have done for me. as for guessing i wasn't guessing i saw those variable and thought to myself maybe those are defined! i wasn't guessing i was trouble shooting something i have no idea about. that is hard to do. i am sorry you guys feel this way however, and for that ill stop posting. i am just excited to see the end and move on to different project with php.

Re: Last question ....How do i make JUST commenting??

Posted: Sun May 06, 2012 5:17 am
by jacek
jaysus7 wrote:i do have an interest or i wouldn't have taken on the job i have, i wouldn't have posted on this forum and i wouldn't have tried to trouble shoot on my own lots of errors. i only call upon you guys when i am lost completely lost, so for helping me i thank you...i have a greater knowledge of php now and i appreciate all you guys have done for me. as for guessing i wasn't guessing i saw those variable and thought to myself maybe those are defined! i wasn't guessing i was trouble shooting something i have no idea about. that is hard to do. i am sorry you guys feel this way however, and for that ill stop posting. i am just excited to see the end and move on to different project with php.
Fair enough :)

You need to go about it in a more logical way rather than taking the brute-force approach.

Lets start with the function
    //fetches all the comments for a given user wall post
    function get_wall_comments($uid){
            $uid = (int)$uid;
           
            $sql = "SELECT
                                   `comment_body` AS `body`,
                                   `comment_user` AS `user`,
                                   DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
                           FROM `wallcomments`
                           WHERE `user_id` = {$uid}";
           
            $comment = mysql_query($sql);
           
            $return = array();
            while (($row = mysql_fetch_assoc($comment)) !== false){
                    $return[] = $row;
            }
                    return $return;
                   
            $comment = mysql_query($sql);
            $comment = mysql_fetch_assoc($comment);
           
            $comment['comment'] = get_wall_comments($comment);
           
           
            return $comment;
    }
You don't want to do the query twice or call the function from within the function, so
    //fetches all the comments for a given user wall post
    function get_wall_comments($uid){
            $uid = (int)$uid;
           
            $sql = "SELECT
                                   `comment_body` AS `body`,
                                   `comment_user` AS `user`,
                                   DATE_FORMAT(`comment_date`, '%d/%m/%Y %H:%i:%s') AS `date`
                           FROM `wallcomments`
                           WHERE `user_id` = {$uid}";
           
            $comment = mysql_query($sql);
           
            $return = array();
            while (($row = mysql_fetch_assoc($comment)) !== false){
                    $return[] = $row;
            }
           
            return $return;
    }
Not the actually error, the problem is that $comment['comment'] is not defined, because the function does not return an array like that. It returns an array of all comments. So you want to do
<?php
 
if (isset($_GET['uid']) === false || valid_uid($_GET['uid']) === false){
        echo 'Be the first to add a comment!';
}else{
        $comments = get_wall_comments($_GET['uid'])
 
        ?>
    <?php
       
        foreach ($comments as $comment){
                ?>
   
         <h3>By: <?php echo $comment['body']; ?> on <?php echo $comment['date']; ?></h3>
     <p><?php echo $comment['user']; ?></p>
     <hr />
     <?php
        }
 
        ?>
<form action="" method="post">
<p>
        <label for="user">Name</label>
    <input type="text" name="user" id="user" value="<?php echo $_SESSION['username']; ?>" />
</p>
<p>
        <textarea name="body" rows="20" cols="60"></textarea>
</p>
<p>
        <input type="submit" value="Add Comment" />
</p>
</form>    
<?php
 
}
 
?>
Make sense ?

Re: Last question ....How do i make JUST commenting??

Posted: Mon May 07, 2012 3:36 am
by jaysus7
Makes sense i was passing the uid variable to the kid variable so i wasn't asking it to pull up the comments. And, the comment to comments makes sense as well!

THANK YOU SO MUCH!!!! I really appreciate your help!!! Sorry for posting so much Jacek, I just really needed help and understanding on how to do it!!!!! YOur The Best!!

Re: Last question ....How do i make JUST commenting??

Posted: Mon May 07, 2012 3:41 pm
by jacek
jaysus7 wrote:THANK YOU SO MUCH!!!! I really appreciate your help!!! Sorry for posting so much Jacek, I just really needed help and understanding on how to do it!!!!! YOur The Best!!
8-)

no problem :D