Jump to content

Error


ecabrera

Recommended Posts

hey when i ftp my file and refresh the page i get a

 

 

Notice: Undefined index: commentbtn in /home/ecabrera/public_html/videos.php on line 94

 

///////line94      if ($_POST['commentbtn']){

 

******code under line 94

 

if ($_POST['commentbtn']){
            $comment = $_POST['comment'];
            
            if ($comment){
               if ($userid != $getid){
                  $query = mysql_query("SELECT * FROM video_comments WHERE video_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 video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");
                     
                     // email profile owner
                     $webmaster = "admin@*******.com";
                     $headers = "From: ********<$webmaster>";
                     $subject = "$username has commented on your profile";
                     $message = "Hello $firstname $lastname. $username has posted a comment on your you video titled \"$title\" on **********.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 profile.php?id=$userid\n";
                     $message .= "Click here to view your video video.php?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 video.";
            }
            else
               $msg = "You did not supply a comment.";
         }
         
         // display comments
         $perpage = 10;if(@$_GET['s']){$start = $_GET['s'];}else{$start = 0;}
         
         $query = mysql_query("SELECT * FROM video_comments WHERE video_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='$/profile?id=$user_id'>$user_name</a> on $date</b><br />";
               echo "<div style='margin-left: 10px;'>$comment</div><hr>";
               
            }
         }
         else
            echo "This video has no comments.<br />";
         // end diplay comment area
         
         // show comment nav
         echo "<div style='float: right;'>";
         
         if (!($start <= 0))
            echo "<a href='video.php?id=$getid&s=$prev#comments'>Previous</a>";
         
         if (!($start > $numrows - $perpage))
            echo "<a href='video.php?id=$getid&s=$next#comments'>Next</a>";
            
         echo "</div>";[/b]

and 

Notice: Undefined variable: username in /home/ecabrera/public_html/videos.php on line 167

////////////line 167

[b]if ($username){

****the rest of the code under 167

 

if ($username){
            // display comment form
            echo "<a name='comment-form'></a>";
            if ($msg)
               echo "<b>$msg</b><br />";
               
            echo "<form action='video.php?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>";
         }

*****a comment box and comment button should appear but it doesnt should that comment box r the sumit button heres the script the comment box should display but it doesnt help me please

 

MOD EDIT: php tags added.

 

Link to comment
Share on other sites

also you have a SQL error on this line

 

mysql_query("INSERT INTO video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

 

 

Also this line.... Unnecessary '@'. Also if $_GET['s'] is empty, then it wil pass the if statement.

 $perpage = 10;if(@$_GET['s']){$start = $_GET['s'];}else{$start = 0;}

 

 

Link to comment
Share on other sites

 

I get this errors and i cant see the comment box are the summit button plz help me r tell me were to fix the script so i can see the comment box i will put the whole comment script so if anyone wants to help

 

 

 

Notice: Undefined index: commentbtn in /home/ecabrera/public_html/videos.php on line 92

 

if ($_POST['commentbtn']){

 

Notice: Undefined index: s in /home/ecabrera/public_html/videos.php on line 131

This video has no comments.

 

$start = $_GET['s'];

 

Notice: Undefined variable: username in /home/ecabrera/public_html/videos.php on line 168

 

if ($username){

 

 

 

		// comment section

		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'>$title Comments</div>
		  </div>
		  
		  <div class='bottom'>";

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

			if ($comment){
				if ($userid != $getid){
					$query = mysql_query("SELECT * FROM video_comments WHERE video_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 video_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 you video titled \"$title\" on BasixNick.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 profile.php?id=$userid\n";
						$message .= "Click here to view your video videos.php?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 video.";
			}
			else
				$msg = "You did not supply a comment.";
		}

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

		$query = mysql_query("SELECT * FROM video_comments WHERE video_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='profile.php?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

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

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

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

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?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='videos.php?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>

		  <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 comment section

		echo "</div>";
		// end left column

	}
	else
		echo "The video you were looking for was not found.";

	// end full and video
	echo "</div>";
	echo "</div>";
}
else{
	echo "<div id='left'>";

	$perpage = 10;
if(@$_GET['s']){
$start = $_GET['s'];
}
else{
$start = 0;
}
	$next = $start + $perpage;
	$prev = $start - $perpage;

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

		// show comment nav
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		/*
		$x = 1;
		for ($i = 0; $i < $numrows; $i += $perpage){
			if ($start != $i)
				echo "<a href='videos.php?s=$i'>$x</a>";
			else
				echo "<a href='videos.php?s=$i'><b><u>$x</u></b></a>";
			$x++;
		}
		*/

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center><br />";

		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$user_id = $row['user_id'];
			$user_name = $row['user_name'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$category = $row['category'];
			$videoid = $row['videoid'];
			$views = $row['views'];
			$comments = $row['comments'];
			$date = $row['date'];

			//$description = $description.$description.$description;

			if (strlen($description) >= 100)
				$description = substr($description, 0, 100)."...";

			echo "<div class='video'>
				<div class='image'><a href='videos.php?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>
				<div class='info'>
					<div class='title'><a href='videos.php?id=$id'>$title</a></div>
					<div class='description'>
						$description
						<br /><br />
						<div style='float: left; font-size: 16px;'><a href='profile.php?id=$user_id'>$user_name</a></div>
						<div style='float: right; font-size: 16px;'>$category</div>
						<center>$views views</center>
					</div>
				</div>
			</div>";

		}

		// show comment nav
		echo "<div class='clear'></div>";
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center>";

	}
	else
		echo "There currently are no videos.";

	echo "</div>";

	echo "<div id='right'></div>";
}

mysql_close();
?>

 

Link to comment
Share on other sites

//using ternary operator to  make sure GET  does not return empty or else to error.
$start= isset($_GET['s']) ? $_GET['s'] : 'start is empty';
//again using ternary operator ro make sure the button has been set or to error
$submit= isset($_POST['commentbtn']) ? $_POST['commentbtn'] : 'comment button is empty';
//making sure username isset or error
$username= isset($_POST['username']) ? $_POST['username'] : 'username is empty';

if($submit){
//insert code here
}

 

 

 

this should fix all your errors  8);)

 

Link to comment
Share on other sites

ok i did the frist  three things but when i refresh my web broweser i go and sever error here is the code  and were should i put the

 

if($submit){

//insert code here

}

 

 

 

sry for asking i new to php and its very confusing

 

// comment section

		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'>$title Comments</div>
		  </div>
		  
		  <div class='bottom'>";

		// comment button action
		$start= isset($_GET['s']) ? $_GET['s'] : 'start is empty';
			$comment = $_POST['comment'];

			if ($comment){
				if ($userid != $getid){
					$query = mysql_query("SELECT * FROM video_comments WHERE video_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 video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

						// email profile owner
						$webmaster = "admin@*******.com";
						$headers = "From: *******<$webmaster>";
						$subject = "$username has commented on your profile";
						$message = "Hello $firstname $lastname. $username has posted a comment on your you video titled \"$title\" on *******.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 profile.php?id=$userid\n";
						$message .= "Click here to view your video videos.php?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 video.";
			}
			else
				$msg = "You did not supply a comment.";
		}

		// display comments
		$perpage = 10;
		$start= isset($_GET['s']) ? $_GET['s'] : 'start is empty';
		if (!$start)
			$start = 0;

		$query = mysql_query("SELECT * FROM video_comments WHERE video_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='profile.php?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

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

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

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

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

		echo "</div>";

		$username= isset($_POST['username']) ? $_POST['username'] : 'username is empty';				// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='videos.php?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>

		  <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 comment section

		echo "</div>";
		// end left column

	}
	else
		echo "The video you were looking for was not found.";

	// end full and video
	echo "</div>";
	echo "</div>";
}
else{
	echo "<div id='left'>";

	$perpage = 10;
if(@$_GET['s']){
$start = $_GET['s'];
}
else{
$start = 0;
}
	$next = $start + $perpage;
	$prev = $start - $perpage;

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

		// show comment nav
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		/*
		$x = 1;
		for ($i = 0; $i < $numrows; $i += $perpage){
			if ($start != $i)
				echo "<a href='videos.php?s=$i'>$x</a>";
			else
				echo "<a href='videos.php?s=$i'><b><u>$x</u></b></a>";
			$x++;
		}
		*/

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center><br />";

		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$user_id = $row['user_id'];
			$user_name = $row['user_name'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$category = $row['category'];
			$videoid = $row['videoid'];
			$views = $row['views'];
			$comments = $row['comments'];
			$date = $row['date'];

			//$description = $description.$description.$description;

			if (strlen($description) >= 100)
				$description = substr($description, 0, 100)."...";

			echo "<div class='video'>
				<div class='image'><a href='videos.php?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>
				<div class='info'>
					<div class='title'><a href='videos.php?id=$id'>$title</a></div>
					<div class='description'>
						$description
						<br /><br />
						<div style='float: left; font-size: 16px;'><a href='profile.php?id=$user_id'>$user_name</a></div>
						<div style='float: right; font-size: 16px;'>$category</div>
						<center>$views views</center>
					</div>
				</div>
			</div>";

		}

		// show comment nav
		echo "<div class='clear'></div>";
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center>";

	}
	else
		echo "There currently are no videos.";

	echo "</div>";

	echo "<div id='right'></div>";
}

mysql_close();
?>

Link to comment
Share on other sites

<?php

// comment section

		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'>$title Comments</div>
		  </div>
		  
		  <div class='bottom'>";

		// comment button action
		$start= isset($_GET['s']) ? $_GET['s'] : '0';
		$comment = isset($_POST['comment']) ? $_POST['comment'] : 'comment is empty.';

			if ($comment){
				if ($userid != $getid){
					$query = mysql_query("SELECT * FROM video_comments WHERE video_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 video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

						// email profile owner
						$webmaster = "admin@*******.com";
						$headers = "From: *******<$webmaster>";
						$subject = "$username has commented on your profile";
						$message = "Hello $firstname $lastname. $username has posted a comment on your you video titled \"$title\" on *******.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 profile.php?id=$userid\n";
						$message .= "Click here to view your video videos.php?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 video.";
			}
			else
				$msg = "You did not supply a comment.";
		}

		// display comments
		$perpage = 10;
		$start= isset($_GET['s']) ? $_GET['s'] : '0';
		if (!$start)
			$start = 0;

		$query = mysql_query("SELECT * FROM video_comments WHERE video_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='profile.php?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

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

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

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

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

		echo "</div>";

		$username= isset($_POST['username']) ? $_POST['username'] : 'username is empty';				// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='videos.php?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>

		  <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 comment section

		echo "</div>";
		// end left column

	}
	else
		echo "The video you were looking for was not found.";

	// end full and video
	echo "</div>";
	echo "</div>";
}
else{
	echo "<div id='left'>";

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

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

		// show comment nav
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		/*
		$x = 1;
		for ($i = 0; $i < $numrows; $i += $perpage){
			if ($start != $i)
				echo "<a href='videos.php?s=$i'>$x</a>";
			else
				echo "<a href='videos.php?s=$i'><b><u>$x</u></b></a>";
			$x++;
		}
		*/

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center><br />";

		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$user_id = $row['user_id'];
			$user_name = $row['user_name'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$category = $row['category'];
			$videoid = $row['videoid'];
			$views = $row['views'];
			$comments = $row['comments'];
			$date = $row['date'];

			//$description = $description.$description.$description;

			if (strlen($description) >= 100)
				$description = substr($description, 0, 100)."...";

			echo "<div class='video'>
				<div class='image'><a href='videos.php?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>
				<div class='info'>
					<div class='title'><a href='videos.php?id=$id'>$title</a></div>
					<div class='description'>
						$description
						<br /><br />
						<div style='float: left; font-size: 16px;'><a href='profile.php?id=$user_id'>$user_name</a></div>
						<div style='float: right; font-size: 16px;'>$category</div>
						<center>$views views</center>
					</div>
				</div>
			</div>";

		}

		// show comment nav
		echo "<div class='clear'></div>";
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center>";

	}
	else
		echo "There currently are no videos.";

	echo "</div>";

	echo "<div id='right'></div>";
}

mysql_close();
?>

Link to comment
Share on other sites

i still can see my page when i refresh this is the whole script maybe u can fix it r find the error i will be so happy if u do

 

<?php
?>
<!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=iso-8859-1" />
<meta name="rating" content="General" />
<meta name="ROBOTS" content="All" />
<title>Videos</title>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</head>

<body>
<?php include_once "header_template.php"; ?>
<table class="mainBodyTable" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="740" valign="top"><div><?php include_once "leaderBoardAd.php"; ?></div><br />
      <table width="90%" align="center" cellpadding="6">
        <tr>
          <td style="line-height:1.7em;"><h2>Videos</h2>
            <?php
require("scripts/checkuserlog.php");

          if(@$_GET['id']){$getid = $_GET['id'];
	echo "<div id='full'>";
	echo "<div id='video'>";

	$query = mysql_query("SELECT * FROM videos WHERE id='$getid'");
	$numrows = mysql_num_rows($query);
	if ($numrows == 1){
		$row = mysql_fetch_assoc($query);
		$id = $row['id'];
		$user_id = $row['user_id'];
		$user_name = $row['user_name'];
		$title = $row['title'];
		$description = $row['description'];
		$keywords = $row['keywords'];
		$category = $row['category'];
		$videoid = $row['videoid'];
		$views = $row['views'];
		$comments = $row['comments'];
		$date = $row['date'];

		$description =($description);	

		// start left column
		echo "<div id='left'>";

		// update the video views
		$views = $views + 1;
		mysql_query("UPDATE videos SET views='$views' WHERE id='$id'");

		// display title
		echo "<h2><a href='videos.php?id=$id'>$title</a></h2>";

		// display video
		echo "
		<object width='640' height='505'>
			<param name='movie' value='http://www.youtube.com/v/".$videoid."&autoplay=0&hl=en_US&fs=1'></param>
			<param name='allowFullScreen' value='true'></param>
			<param name='allowscriptaccess' value='always'></param>
			<embed src='http://www.youtube.com/v/".$videoid."&autoplay=0&hl=en_US&fs=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='640' height='505'></embed>
		</object>";

		// display information
		echo "<b style='float: right;'>$views views</b>";
		echo "<b><a href='profile.php?id=$user_id'>$user_name</a> on $date in $category</b><br /><br />";
		echo "$description<br /><br />$keywords";


		// comment section

		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'>$title Comments</div>
		  </div>
		  
		  <div class='bottom'>";

		// comment button action
		$start= isset($_GET['s']) ? $_GET['s'] : '0';
		$comment = isset($_POST['comment']) ? $_POST['comment'] : 'comment is empty.';

			if ($comment){
				if ($userid != $getid){
					$query = mysql_query("SELECT * FROM video_comments WHERE video_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 video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

						// email profile owner
						$webmaster = "admin@*******.com";
						$headers = "From: *******<$webmaster>";
						$subject = "$username has commented on your profile";
						$message = "Hello $firstname $lastname. $username has posted a comment on your you video titled \"$title\" on *******.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 profile.php?id=$userid\n";
						$message .= "Click here to view your video videos.php?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 video.";
			}
			else
				$msg = "You did not supply a comment.";
		}

		// display comments
		$perpage = 10;
		$start= isset($_GET['s']) ? $_GET['s'] : '0';
		if (!$start)
			$start = 0;

		$query = mysql_query("SELECT * FROM video_comments WHERE video_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='profile.php?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

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

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

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

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

		echo "</div>";

		$username= isset($_POST['username']) ? $_POST['username'] : 'username is empty';				// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='videos.php?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>

		  <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 comment section

		echo "</div>";
		// end left column

	}
	else
		echo "The video you were looking for was not found.";

	// end full and video
	echo "</div>";
	echo "</div>";
}
else{
	echo "<div id='left'>";

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

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

		// show comment nav
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		/*
		$x = 1;
		for ($i = 0; $i < $numrows; $i += $perpage){
			if ($start != $i)
				echo "<a href='videos.php?s=$i'>$x</a>";
			else
				echo "<a href='videos.php?s=$i'><b><u>$x</u></b></a>";
			$x++;
		}
		*/

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center><br />";

		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$user_id = $row['user_id'];
			$user_name = $row['user_name'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$category = $row['category'];
			$videoid = $row['videoid'];
			$views = $row['views'];
			$comments = $row['comments'];
			$date = $row['date'];

			//$description = $description.$description.$description;

			if (strlen($description) >= 100)
				$description = substr($description, 0, 100)."...";

			echo "<div class='video'>
				<div class='image'><a href='videos.php?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>
				<div class='info'>
					<div class='title'><a href='videos.php?id=$id'>$title</a></div>
					<div class='description'>
						$description
						<br /><br />
						<div style='float: left; font-size: 16px;'><a href='profile.php?id=$user_id'>$user_name</a></div>
						<div style='float: right; font-size: 16px;'>$category</div>
						<center>$views views</center>
					</div>
				</div>
			</div>";

		}

		// show comment nav
		echo "<div class='clear'></div>";
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center>";

	}
	else
		echo "There currently are no videos.";

	echo "</div>";

	echo "<div id='right'></div>";
}

mysql_close();
?>
            <h2><br />
            </h2></td>
        </tr>
      </table></td>
    <td width="160" valign="top"><?php include_once "right_AD_template.php"; ?></td>
  </tr>
</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>

Link to comment
Share on other sites

its not like a phph error its like this

 

 

Server error

The website encountered an error while retrieving http://********.com/videos.php. It may be down for maintenance or configured incorrectly.

Here are some suggest

 

this only happen after i put darkfreaks code in if i put my code init come up normally and with the three errors i said before

Link to comment
Share on other sites


<!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=iso-8859-1" />
<meta name="rating" content="General" />
<meta name="ROBOTS" content="All" />
<title>Videos</title>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</head>

<body>
<?php include_once "header_template.php"; ?>
<table class="mainBodyTable" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="740" valign="top"><div><?php include_once "leaderBoardAd.php"; ?></div><br />
      <table width="90%" align="center" cellpadding="6">
        <tr>
          <td style="line-height:1.7em;"><h2>Videos</h2>
            <?php
require("scripts/checkuserlog.php");


$id= isset($_GET['id']) ? $_GET['id'] : 'ID is empty.';
	echo "<div id='full'>";
	echo "<div id='video'>";

	$query = mysql_query("SELECT * FROM videos WHERE id='$getid'");
	$numrows = mysql_num_rows($query);
	if ($numrows == 1){
		$row = mysql_fetch_assoc($query);
		$id = $row['id'];
		$user_id = $row['user_id'];
		$user_name = $row['user_name'];
		$title = $row['title'];
		$description = $row['description'];
		$keywords = $row['keywords'];
		$category = $row['category'];
		$videoid = $row['videoid'];
		$views = $row['views'];
		$comments = $row['comments'];
		$date = $row['date'];

		$description =($description);	

		// start left column
		echo "<div id='left'>";

		// update the video views
		$views = $views + 1;
		mysql_query("UPDATE videos SET views='$views' WHERE id='$id'");

		// display title
		echo "<h2><a href='videos.php?id=$id'>$title</a></h2>";

		// display video
		echo "
		<object width='640' height='505'>
			<param name='movie' value='http://www.youtube.com/v/".$videoid."&autoplay=0&hl=en_US&fs=1'></param>
			<param name='allowFullScreen' value='true'></param>
			<param name='allowscriptaccess' value='always'></param>
			<embed src='http://www.youtube.com/v/".$videoid."&autoplay=0&hl=en_US&fs=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='640' height='505'></embed>
		</object>";

		// display information
		echo "<b style='float: right;'>$views views</b>";
		echo "<b><a href='profile.php?id=$user_id'>$user_name</a> on $date in $category</b><br /><br />";
		echo "$description<br /><br />$keywords";


		// comment section

		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'>$title Comments</div>
		  </div>
		  
		  <div class='bottom'>";

		// comment button action
		$start= isset($_GET['s']) ? $_GET['s'] : '0';
		$comment = isset($_POST['comment']) ? $_POST['comment'] : 'comment is empty.';

			if ($comment){
				if ($userid != $getid){
					$query = mysql_query("SELECT * FROM video_comments WHERE video_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 video_comments VALUES ('', '$getid', '$userid', '$username', '$comment', '$commdate')");

						// email profile owner
						$webmaster = "admin@*******.com";
						$headers = "From: *******<$webmaster>";
						$subject = "$username has commented on your profile";
						$message = "Hello $firstname $lastname. $username has posted a comment on your you video titled \"$title\" on *******.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 profile.php?id=$userid\n";
						$message .= "Click here to view your video videos.php?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 video.";
			}
			else
				$msg = "You did not supply a comment.";
		}

		// display comments
		$perpage = 10;
		$start= isset($_GET['s']) ? $_GET['s'] : '0';
		if (!$start)
			$start = 0;

		$query = mysql_query("SELECT * FROM video_comments WHERE video_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='profile.php?id=$user_id'>$user_name</a> on $date</b><br />";
				echo "<div style='margin-left: 10px;'>$comment</div><hr>";

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

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

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

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

		echo "</div>";

		$username= isset($_POST['username']) ? $_POST['username'] : 'username is empty';				// display comment form
			echo "<a name='comment-form'></a>";
			if ($msg)
				echo "<b>$msg</b><br />";

			echo "<form action='videos.php?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>

		  <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 comment section

		echo "</div>";
		// end left column



		echo "The video you were looking for was not found.";

	// end full and video
	echo "</div>";
	echo "</div>";

	echo "<div id='left'>";

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

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

		// show comment nav
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		/*
		$x = 1;
		for ($i = 0; $i < $numrows; $i += $perpage){
			if ($start != $i)
				echo "<a href='videos.php?s=$i'>$x</a>";
			else
				echo "<a href='videos.php?s=$i'><b><u>$x</u></b></a>";
			$x++;
		}
		*/

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center><br />";

		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$user_id = $row['user_id'];
			$user_name = $row['user_name'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$category = $row['category'];
			$videoid = $row['videoid'];
			$views = $row['views'];
			$comments = $row['comments'];
			$date = $row['date'];

			//$description = $description.$description.$description;

			if (strlen($description) >= 100)
				$description = substr($description, 0, 100)."...";

			echo "<div class='video'>
				<div class='image'><a href='videos.php?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>
				<div class='info'>
					<div class='title'><a href='videos.php?id=$id'>$title</a></div>
					<div class='description'>
						$description
						<br /><br />
						<div style='float: left; font-size: 16px;'><a href='profile.php?id=$user_id'>$user_name</a></div>
						<div style='float: right; font-size: 16px;'>$category</div>
						<center>$views views</center>
					</div>
				</div>
			</div>";

		}

		// show comment nav
		echo "<div class='clear'></div>";
		echo "<center><div class='pagination'>";

		if (!($start <= 0))
			echo "<a href='videos.php?s=$prev'>Previous</a>";

		if (!($start > $numrows - $perpage))
			echo "<a href='videos.php?s=$next'>Next</a>";

		echo "</div></center>";

	}
	else
		echo "There currently are no videos.";

	echo "</div>";


mysql_close();
?>
            <h2><br />
            </h2></td>
        </tr>
      </table></td>
    <td width="160" valign="top"><?php include_once "right_AD_template.php"; ?></td>
  </tr>
</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>

 

 

there were alot of useless ELSE statements sense all your IF statements are now ternary operators

Link to comment
Share on other sites

good news and bad new is that i saw the comment box and the summit but its was not like i expected it to be like ok ima make it more clear so you could understand on the videos page its like youtube style where u see all the videos list  and when you click on a video it is suppose  brings you to the video with a comment box so you can commented if u want to but with the code you fix everything was on the videos page

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.