ecabrera Posted July 28, 2011 Share Posted July 28, 2011 hey can some one help me i have this script but when i upload it and try it works fine except when i click on a video it doesnt show the comment box or the summit button plz if someone is willin to help me out i will insert the whole script to see whats the problem it shows me this and also this shows up idk whats up plz help Notice: Undefined index: commentbtn in /home/ecabrera/public_html/videos.php on line 94 Notice: Undefined variable: username in /home/ecabrera/public_html/videos.php on line 167 <?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 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.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='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>"; 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>"; } // 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 More sharing options...
WebStyles Posted July 28, 2011 Share Posted July 28, 2011 those errors mean $_POST['commentbtn'] and $username are not reaching your script. Link to comment Share on other sites More sharing options...
mikosiko Posted July 28, 2011 Share Posted July 28, 2011 variable $username doesn't exists .... you have one called $user_name ... therefore your comment form is not show and commentbtn is not setup Link to comment Share on other sites More sharing options...
ecabrera Posted July 28, 2011 Author Share Posted July 28, 2011 ok but how do i fix this errors im new to php its kinda confuseing Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2011 Share Posted July 28, 2011 Don't you already have a thread open for this same problem? Link to comment Share on other sites More sharing options...
ecabrera Posted July 28, 2011 Author Share Posted July 28, 2011 No that was another problem this is different so can any body help plz I really need it Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2011 Share Posted July 28, 2011 So the same error message, on the same line, in the same code is a different problem? Link to comment Share on other sites More sharing options...
ecabrera Posted July 28, 2011 Author Share Posted July 28, 2011 I just need help ok Link to comment Share on other sites More sharing options...
Recommended Posts