Jump to content

help


ecabrera

Recommended Posts

help with this plz

when i i got to a profile i cant see the comment it shows like this

 

Notice: Undefined index: comment in /home/ecabrera/public_html/profile.php on line 179

$comment = nl2br ($row['comment']);

 

and when i add a comment i get this

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ecabrera/public_html/profile.php on line 128

 

	$numerows = mysql_num_rows($query);

 

 

Link to comment
Share on other sites

help with this please

We got that from your title.

 

Undefined index:

Post more of the relevant code.  Are you selecting this from a DB?  If not, how is this array being generated?

 

supplied argument is not a valid MySQL result

Usually caused by an invalid query.  Again, post more relevant code.

Link to comment
Share on other sites

			// comment button action
		if (@$_POST['commentbtn']){
			if ($username){
				$comment = $_POST['comment'];

				if ($comment){
					if ($userid != $getid){
						$query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' AND user_id='$userid' AND comment='$comment'");
						$numerows = mysql_num_rows($query);
						if ($numrows != 0){
							$commdate = date("F d, Y"); // October 08, 2010
							mysql_query("INSERT INTO profile_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

							// email profile owner
							$webmaster = "admin@maliferulez.com";
							$headers = "From: Ma Life Rulez<$webmaster>";
							$subject = "$username has commented on your profile";
							$message = "Hello $firstname $lastname. $username has posted a comment on your profile on Maliferulez.com";
							$message .= " The message $username has posted with is below.\n";
							$message .= "\n****************************************************************\n";
							$message .= "$comment";
							$message .= "\n\n****************************************************************\n\n";
							$message .= "Click here to view $username's profile $site/profile?id=$userid\n";
							$message .= "Click here to view your profile $site/profile?id=$getid\n";
							// send email
							mail($email, $subject, $message, $headers);

							$msg = "Your comment has been added and is shown above.";
						}
						else
							$msg = "You can not submit the same comment twice.";
					}
					else
						$msg = "You can not comment on your own profile.";
				}
				else
					$msg = "You did not supply a comment.";
			}
			else
				$msg = "You must be logged in to comment on profiles.";
		}

		// display comments
		$perpage = 10;
		$start=0;
		if(@$_GET['s'])
		$start = $_GET['s'];


		$query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' ORDER BY id DESC LIMIT $start, $perpage");
		$numrows = mysql_num_rows($query);
		if ($numrows > 0){

			$next = $start + $perpage;
			$prev = $start - $perpage;

			while($row = mysql_fetch_assoc($query)){
				$user_id = $row['user_id'];
				$user_name = $row['user_name'];
				$comment = nl2br ($row['comment']);
				$date = $row['date'];

				echo "<b>Posted by <a href='$site/profile?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

			}
		}
		else
			echo "This user has no profile comments.<br />";
		// end diplay comment area

		// show comment nav
		echo "<div style='float: right;'>";

		if (!($start <= 0))
			echo "<a href='$site/profile?id=$getid&s=$prev#comments'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='$site/profile?id=$getid&s=$next#comments'>Next</a>";

		echo "</div>";

		if ($username){
			// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='$site/profile?id=$getid#comment-form' method='post'>
			<table>
			<tr>
				<td><textarea name='comment' style='width: 400px; height: 75px;'></textarea></td>
			</tr>
			<tr>
				<td><input type='submit' name='commentbtn' value='Comment'></td>
			</tr>
			</table>
			</form>";
		}

		// end comment box
		echo "</div></div>

		  <b class='corners'>
		  <b class='corners5'></b>
		  <b class='corners4'></b>
		  <b class='corners3'></b>
		  <b class='corners2'><b></b></b>
		  <b class='corners1'><b></b></b></b>
		</div>";

Link to comment
Share on other sites

nope and i did tryed it but i took your code of when it didnt work

 

<?php
$getid="";
if(@$_GET['id'])
$getid = $_GET['id'];

if ($getid){
require('scripts/connect.php');
$query = mysql_query("SELECT * FROM users WHERE id='$getid'");
$numrows = mysql_num_rows($query);

if ($numrows == 1){
	$row = mysql_fetch_assoc($query);
	$user = $row['username'];
	$bio = $row['bio'];
	$youtube = $row['youtube'];

	$title = "$user's Profile on Maliferulez";
	$meta_description = "$bio";
	$meta_keywords = "$youtube";

}
else
	$title = "Opps!!! Profile not found!";

mysql_close();
}
else
$title = "Profiles";

?>
<?php require("styles/top.php"); ?>

<div id='full'>
<?php
$msg="";
if (!$getid)
	$getid = "1";

require('scripts/connect.php');	
$query = mysql_query("SELECT * FROM users WHERE id='$getid'");
$numrows = mysql_num_rows($query);

if ($numrows == 1){
	$row = mysql_fetch_assoc($query);

	$id = $row['id'];
	$firstname = $row['first_name'];
	$lastname = $row['last_name'];
	$user = $row['username'];
	$email = $row['email'];
	$avatar = $row['avatar'];
	$bio = nl2br($row['bio']);
	$youtube = $row['youtube'];
	$lastlogin = $row['last_login'];
	$active = $row['active'];
	$locked = $row['locked'];
	$date = $row['date'];

	if ($locked == 0){

		echo "<div id='profile'>
		<div id='leftside'>
			<img src='avatars/$avatar' width='250px' height='250px' style='border: 3px double #000;'></img>
		</div>

		<div id='rightside'>
		<div>
		  <b class='corners'>
		  <b class='corners1'><b></b></b>
		  <b class='corners2'><b></b></b>
		  <b class='corners3'></b>
		  <b class='corners4'></b>
		  <b class='corners5'></b></b>

		  <div class='cornersfg'>
			<div class='top'>$user's Profile</div>
		  </div>
		  

		  <div class='bottom'>
			<b>Joined</b> - $date<br />
			<b>Last Login</b> -  $lastlogin<br />";



		if ($youtube)
			echo "<br /><b><u>Youtube Channel:</u></b><br /> <a href='http://www.youtube.com/$youtube'>$youtube</a><br />";

		if ($bio)
			echo "<br/>$bio";

		echo "</div>

		  <b class='corners'>
		  <b class='corners5'></b>
		  <b class='corners4'></b>
		  <b class='corners3'></b>
		  <b class='corners2'><b></b></b>
		  <b class='corners1'><b></b></b></b>
		</div>";
		/*
		if ($youtube)
			echo "<script src='http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&up_channel=$youtube&synd=open&w=275&h=390&title=&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js'></script>";
		*/

		echo "<a name='comments'></a><div style='margin-top: 15px;'>
		  <b class='corners'>
		  <b class='corners1'><b></b></b>
		  <b class='corners2'><b></b></b>
		  <b class='corners3'></b>
		  <b class='corners4'></b>
		  <b class='corners5'></b></b>

		  <div class='cornersfg'>
			<div class='top'>$user's Profile Comments</div>
		  </div>
		  
		  <div class='bottom'>";

		// comment button action
		if (@$_POST['commentbtn']){
			if ($username){
				$comment = $_POST['comment'];

				if(!empty($comment)){
					if (!empty($userid) != $getid){
						$query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' AND user_id='$userid' AND comment='$comment'");
						$numerows = mysql_num_rows($query);
						if ($numrows != 0){
							$commdate = date("F d, Y"); // October 08, 2010
							mysql_query("INSERT INTO profile_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

							// email profile owner
							$webmaster = "admin@maliferulez.com";
							$headers = "From: Ma Life Rulez<$webmaster>";
							$subject = "$username has commented on your profile";
							$message = "Hello $firstname $lastname. $username has posted a comment on your profile on Maliferulez.com";
							$message .= " The message $username has posted with is below.\n";
							$message .= "\n****************************************************************\n";
							$message .= "$comment";
							$message .= "\n\n****************************************************************\n\n";
							$message .= "Click here to view $username's profile $site/profile?id=$userid\n";
							$message .= "Click here to view your profile $site/profile?id=$getid\n";
							// send email
							mail($email, $subject, $message, $headers);

							$msg = "Your comment has been added and is shown above.";
						}
						else
							$msg = "You can not submit the same comment twice.";
					}
					else
						$msg = "You can not comment on your own profile.";
				}
				else
					$msg = "You did not supply a comment.";
			}
			else
				$msg = "You must be logged in to comment on profiles.";
		}

		// display comments
		$perpage = 10;
		$start=0;
		if(@$_GET['s'])
		$start = $_GET['s'];


		$query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' ORDER BY id DESC LIMIT $start, $perpage");
		$numrows = mysql_num_rows($query);
		if ($numrows > 0){

			$next = $start + $perpage;
			$prev = $start - $perpage;

			while($row = mysql_fetch_assoc($query)){
				$user_id = $row['user_id'];
				$user_name = $row['user_name'];
				$comment = nl2br ($row['comment']);
				$date = $row['date'];

				echo "<b>Posted by <a href='$site/profile?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

			}
		}
		else
			echo "This user has no profile comments.<br />";
		// end diplay comment area

		// show comment nav
		echo "<div style='float: right;'>";

		if (!($start <= 0))
			echo "<a href='$site/profile?id=$getid&s=$prev#comments'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='$site/profile?id=$getid&s=$next#comments'>Next</a>";

		echo "</div>";

		if ($username){
			// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='$site/profile?id=$getid#comment-form' method='post'>
			<table>
			<tr>
				<td><textarea name='comment' style='width: 400px; height: 75px;'></textarea></td>
			</tr>
			<tr>
				<td><input type='submit' name='commentbtn' value='Comment'></td>
			</tr>
			</table>
			</form>";
		}

		// end comment box
		echo "</div></div>

		  <b class='corners'>
		  <b class='corners5'></b>
		  <b class='corners4'></b>
		  <b class='corners3'></b>
		  <b class='corners2'><b></b></b>
		  <b class='corners1'><b></b></b></b>
		</div>";

		// end right column
		echo "</div>";
	}
	else
		echo "<font color='red'><center><h1>The profile you have selected is currently locked.</h1></center></font>";
}
else
	echo "No user was found.";

?>
</div>




<div id='left'>

</div>

<div id='right'>

</div>

<?php require("styles/bottom.php"); ?>

Link to comment
Share on other sites

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.