Jump to content

Recommended Posts

hello all. I need help.

Here is the problem. My web site has a comment area and the posting of comments works fine. And you have to be a persons friend to be able to comment them thats fine 2. But the problem is when you are on somones profile it lists thier comments but instead of the commentors name the commentees name is posted.

Like this for ex.

 

Welcome Mc. Duffs

--------------------

Comments-

Mc. Duffs      Nice Profile

 

(when the mc. duffs should be s4t4n)

 

and im sure that it is a mysql pull problem so here is that code

<?php
$bsql = "SELECT * FROM ".$glob['dbprefix']."StreamRush_profileComments LEFT JOIN ".$glob['dbprefix']."StreamRush_customer on ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."StreamRush_profileComments.customer_id WHERE deleted = 0 AND ".$glob['dbprefix']."StreamRush_profileComments.from_customer_id =".$ccUserData[0]['customer_id']." AND ".$glob['dbprefix']."StreamRush_profileComments.customer_id = ".$_GET['customer_id']."  ORDER BY time DESC";
$bArray = $db->select($bsql, $config['productPages'], $page);
?>

And here is the key terms i use in the database

 

  id |  customer_id  |  from_customer_id  |  comment  |  time  |  deleted

        (this is the      (from this person)

        person who

        will receive)

 

and if you need it here is the full code for the comments area.

<?php
if($_GET['customer_id']>0){
$bsql = "SELECT * FROM ".$glob['dbprefix']."StreamRush_profileComments LEFT JOIN ".$glob['dbprefix']."StreamRush_customer on ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."StreamRush_profileComments.customer_id WHERE deleted = 0 AND ".$glob['dbprefix']."StreamRush_profileComments.from_customer_id =".$ccUserData[0]['customer_id']." AND ".$glob['dbprefix']."StreamRush_profileComments.customer_id = ".$_GET['customer_id']."  ORDER BY time DESC";
$bArray = $db->select($bsql, $config['productPages'], $page);

$totalNoProducts = $db->numrows($bsql);

	$box_content->assign("NUMBER","Comments Made: ".count($bArray));
for($i=0;$i<count($bArray); $i++){
	$box_content->assign("TXT_NAME",$bArray[$i]['screenname']);
	$box_content->assign("TXT_COMMENT",$bArray[$i]['comment']);
	$box_content->assign("PAGINATION",$db->paginate($totalNoProducts, $config['productPages'], $page, "page"));

$box_content->parse("comments.comment_loop");
}

$db = new db();
$query = "SELECT * FROM ".$glob['dbprefix']."StreamRush_profileComments WHERE customer_id = ".$_GET['customer_id'];
$results = $db->select($query);	
$bsql="SELECT * FROM ".$glob['dbprefix']."StreamRush_friends where customer_id = ".$ccUserData[0]['customer_id']." AND friend_id= ".$_GET['customer_id']." OR  customer_id = ".$_GET['customer_id']." AND friend_id= ".$ccUserData[0]['customer_id']." AND pending = 0";
$fArray = $db->select($bsql);
$record["comment"] = $db->mySQLSafe($_POST['comment']);		
$record["customer_id"] = $db->mySQLSafe($_GET['customer_id']);	
$record["from_customer_id"] = $db->mySQLSafe($_POST['customer_id']);	

	if($ccUserData[0]['customer_id'] == $_GET['customer_id']){
			if(isset($_POST['comment'])) {
	$box_content->assign("MSG","<td bgcolor='#990000' colspan='2'>Sorry ".$bArray['screenname']." You Cant Comment Yourself!</td>");
	}
	}elseif($fArray==FALSE){
			if(isset($_POST['comment'])) {
	$box_content->assign("MSG","<td bgcolor='#990000' colspan='2'>Sorry ".$bArray['screenname']." You Cant Just Comment Anyone! Invite to friends first!</td>");
}
	}elseif($fArray==TRUE){
	if(isset($_POST['comment'])) {
		$insert = $db->insert($glob['dbprefix']."StreamRush_profileComments", $record);
	$box_content->assign("MSG","<td bgcolor='#990000' colspan='2'>Well ".$bArray['screenname']." You Created A Comment All By Yourself!</td>");
	}}

if($_GET["edit"]>0){
$box_content->assign("VAL_ACTION","index.php?act=viewProfile&edit=".$_GET['comment_id']."&from_customer_id=".$results['from_customer_id']."&customer_id=".$_GET['customer_id']."&comment_id=".$_GET['comment_id']);
}else{ 
$box_content->assign("VAL_ACTION","index.php?act=viewProfile&customer_id=".$_GET['customer_id']);}
if(isset($_GET['comment_id'])>0 || isset($_GET['customer_id'])==$ccUserData[0]['customer_id']){
$box_content->assign("TXT_COMMENT",$results['comment']);}
 if(isset($_GET['edit'])>0 || isset($_GET['customer_id'])==$ccUserData[0]['customer_id']) {
$box_content->assign("CUSTOMER_ID",$ccUserData[0]['customer_id']);}
 if(isset($_GET['comment_id'])>0 || isset($_GET['customer_id'])==$ccUserData[0]['customer_id'] ){
$box_content->assign("PRODUCT_ID",$_GET['productId']);}
if($_GET["edit"]>0){
$box_content->assign("VAL_INPUT","Update Comment");
 }else{ 
$box_content->assign("VAL_INPUT","Create Comment");
}
$box_content->parse("comments.comment_create");
}
?>

and header has customer_id= in it

Link to comment
https://forums.phpfreaks.com/topic/72812-solved-posting-wrong-name-on-comments/
Share on other sites

Perhaps you should join on where the customer_id = from_customer_id. I'm guessing you are currently joining all the rows to the owner's ID (since that's what customer_id is according to you), rather than the commentor's ID.

 

In other words, you should rather be using:

 

$bsql = "SELECT * FROM ".$glob['dbprefix']."StreamRush_profileComments LEFT JOIN ".$glob['dbprefix']."StreamRush_customer on ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."StreamRush_profileComments.from_customer_id WHERE deleted = 0 AND ".$glob['dbprefix']."StreamRush_profileComments.from_customer_id =".$ccUserData[0]['customer_id']." AND ".$glob['dbprefix']."StreamRush_profileComments.customer_id = ".$_GET['customer_id']."  ORDER BY time DESC";

 

ps. Your code is not exactly what I'd call "readable".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.