Jump to content

Recommended Posts

hey im create a website where you can add videos and i created this script but i dont know whats wrong  :confused: i cant find the error r maybe its in front of me but im so sleepy i can even see it. when i click add video it does not add it it brings me to a none exsiting page help me *i also create the page where the videos are going to be posted heres the script for the add video script

 

$categories = "

<option value='HTML and CSS'>HTML and CSS</option>

<option value='PHP and MySql'>PHP and MySql</option>

";

 

$form = "<form action='$site/addvideo' method='post'>

<table>

<tr>

<td>Title:</td>

<td><input type='text' name='title' style='width: 450px;'></td>

</tr>

<tr>

<td>Description:</td>

<td><textarea name='description' style='width: 450px; height: 100px;'></textarea></td>

</tr>

<tr>

<td>Keywords:</td>

<td><input type='text' name='keywords' style='width: 450px;'></td>

</tr>

<tr>

<td>Category:</td>

<td><select name='category' style='width: 455px;'>

<option value=''>Select One</option>

$categories

</select></td>

</tr>

<tr>

<td>Video ID:</td>

<td><input type='text' name='videoid' maxlength='20' style='width: 450px;'><br />

Not the entire URL just the video ID! Just the part in RED!!!<br />

http://www.youtube.com/watch?v=<font color='red'>SoKQz065aQU</font></td>

</tr>

<tr>

<td></td>

<td><input type='submit' name='addbtn' value='Add Video'></td>

</tr>

</table>

</form>";

 

if ($_POST['addbtn']){

$title = $_POST['title'];

$description = $_POST['description'];

$keywords = $_POST['keywords'];

$category = $_POST['category'];

$videoid = $_POST['videoid'];

 

if ($title){

if ($description){

if ($keywords){

if ($category){

if ($videoid){

if (strstr($categories, "<option value='$category'>$category</option>")){

require("scripts/checkuserlog.php");

 

$query = mysql_query("SELECT * FROM videos WHERE videoid='$videoid'");

$numrows = mysql_num_rows($query);

if ($numrows == 0){

 

$date = date("F d, Y"); // October 09, 2010

mysql_query("INSERT INTO videos VALUES ('', '$userid', '$username', '$title', '$description', '$keywords', '$category', '$videoid', '0', '0', '$date')");

$query = mysql_query("SELECT * FROM videos WHERE user_id='$userid' AND title='$title' AND videoid='$videoid'");

$numrows = mysql_num_rows($query);

if ($numrows == 1){

$row = mysql_fetch_assoc($query);

$id = $row['id'];

 

echo "Your video has been added. <a href='$site/videos?id=$id'>Click here to view it.</a>";

 

}

else

echo "<font color='red'>Your video was not added to the database for some reason.</font>";

}

else

echo "You can not add a video that is already in the database. $form";

 

mysql_close();

}

else

echo "You did not submit a valid category. $form";

}

else

echo "You did not submit a video ID. $form";

}

else

echo "You did not select a category. $form";

}

else

echo "You did not submit any keywords. $form";

}

else

echo "You did not submit a description. $form";

}

else

echo "You did not submit a title. $form";

}

else

echo "$form";

 

?>

</div>

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/
Share on other sites

hey i fixed the add video but can someone tell me why i can see me videos when i click oh one of my videos that in the db plz help i will provide the videos page and the add video page can any body try to help me or correct error plz

 

video page

* i get this

 

Notice: Undefined variable: getid in /home/ecabrera/public_html/videos.php on line 28

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

 

video page script

 

<?php

require("scripts/checkuserlog.php");

 

if ($getid){

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 = htmltext($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='$/video?id=$id'>$title</a></h2>";

 

// display video

echo "

<object width='640' height='505'>

<param name='movie' value='http://www.youtube.com/watch?v=".$videoid."&autoplay=1&hl=en_US&fs=1'></param>

<param name='allowFullScreen' value='true'></param>

<param name='allowscriptaccess' value='always'></param>

<embed src='http://www.youtube.com/watch?v=".$videoid."&autoplay=1&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?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 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?id=$userid\n";

$message .= "Click here to view your video /video?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?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='$site/video?id=$getid&s=$prev#comments'>Previous</a>";

 

if (!($start > $numrows - $perpage))

echo "<a href='$site/video?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/video?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;

        $start = $_GET['s'];

if (!$start)

$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='$site/videos?s=$prev'>Previous</a>";

 

/*

$x = 1;

for ($i = 0; $i < $numrows; $i += $perpage){

if ($start != $i)

echo "<a href='$site/videos?s=$i'>$x</a>";

else

echo "<a href='$site/videos?s=$i'><b><u>$x</u></b></a>";

$x++;

}

*/

 

if (!($start > $numrows - $perpage))

echo "<a href='$site/videos?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?id=$id'><img src='http://i1.ytimg.com/vi/$videoid/default.jpg'></img></a></div>

<div class='info'>

<div class='title'><a href='videos?id=$id'>$title</a></div>

<div class='description'>

$description

<br /><br />

<div style='float: left; font-size: 16px;'><a href='profile?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='$site/videos?s=$prev'>Previous</a>";

 

if (!($start > $numrows - $perpage))

echo "<a href='$site/videos?s=$next'>Next</a>";

 

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

 

}

else

echo "There currently are no videos.";

 

echo "</div>";

 

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

}

 

mysql_close();

?>

 

this is add video page

 

<?php

 

$categories = "

<option value='HTML and CSS'>HTML and CSS</option>

<option value='PHP and MySql'>PHP and MySql</option>

";

 

$form = "<form action='addvideo.php' method='post'>

<table>

<tr>

<td>Title:</td>

<td><input type='text' name='title' style='width: 450px;'></td>

</tr>

<tr>

<td>Description:</td>

<td><textarea name='description' style='width: 450px; height: 100px;'></textarea></td>

</tr>

<tr>

<td>Keywords:</td>

<td><input type='text' name='keywords' style='width: 450px;'></td>

</tr>

<tr>

<td>Category:</td>

<td><select name='category' style='width: 455px;'>

<option value=''>Select One</option>

$categories

</select></td>

</tr>

<tr>

<td>Video ID:</td>

<td><input type='text' name='videoid' maxlength='20' style='width: 450px;'><br />

Not the entire URL just the video ID! Just the part in RED!!!<br />

http://www.youtube.com/watch?v=<font color='red'>SoKQz065aQU</font></td>

</tr>

<tr>

<td></td>

<td><input type='submit' name='addbtn' value='Add Video'></td>

</tr>

</table>

</form>";

 

if ($_POST['addbtn']){

$title = $_POST['title'];

$description = $_POST['description'];

$keywords = $_POST['keywords'];

$category = $_POST['category'];

$videoid = $_POST['videoid'];

 

if ($title){

if ($description){

if ($keywords){

if ($category){

if ($videoid){

if (strstr($categories, "<option value='$category'>$category</option>")){

require("scripts/checkuserlog.php");

 

$query = mysql_query("SELECT * FROM videos WHERE videoid='$videoid'");

$numrows = mysql_num_rows($query);

if ($numrows == 0){

 

$date = date("F d, Y"); // October 09, 2010

mysql_query("INSERT INTO videos VALUES ('', 'user_id', 'user_name', '$title', '$description', '$keywords', '$category', '$videoid', '0', '0', '$date')");

$query = mysql_query("SELECT * FROM videos WHERE user_id='id' AND title='$title' AND videoid='$videoid'");

$numrows = mysql_num_rows($query);

if ($numrows == 1){

$row = mysql_fetch_assoc($query);

$id = $row['id'];

 

echo "Your video has been added. <a href='videos.php=$id'>Click here to view it.</a>";

 

}

else

echo "<font color='red'>Your video was not added to the database for some reason.</font>";

}

else

echo "You can not add a video that is already in the database. $form";

 

mysql_close();

}

else

echo "You did not submit a valid category. $form";

}

else

echo "You did not submit a video ID. $form";

}

else

echo "You did not select a category. $form";

}

else

echo "You did not submit any keywords. $form";

}

else

echo "You did not submit a description. $form";

}

else

echo "You did not submit a title. $form";

}

else

echo "$form";

 

?>

</div>

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247755
Share on other sites

Only post the peace of code where the question is about. People aint gonna read all that just to help you.

 

NO.  Please post as much code as is relevent, people have, will and do read through it just to help people. 

 

That said @ecabrera do also read the forum rules before posting: ALWAYS post code within the relevent tags! What is your actual problem? If there is an error code please post it with the question, if there is not please fully explain what the code is doing versus what you think/expect the code should do.

 

Do this and we will help you.  As it stands all I see is that you have some nitices about undeclaired identifiers which is comon when you are checking for if($variable){} and can be avoided by using if(@$variable){}.

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247773
Share on other sites

ok thanks i like people like u that are willing to help  :D

ok when i go to my videos page i get  this

 

 

Notice: Undefined variable: getid in /home/ecabrera/public_html/videos.php on line 28

 

if ($getid){

 

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

 

$start = $_GET['s'];

 

and when i click on a video to see it i get a not found error even though that video is in my database

its not letting me see the video

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247777
Share on other sites

ok, there are a few niggles with your code, but we'll leve those aside just now.  In your video page script change you line

if($getid){

to

if(@$_GET['id']){$getid = $_GET['id'];

and change

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

to

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

 

let us know how that goes.

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247785
Share on other sites

the database should only be storing the path to the video - you will need to check the server to see if the video files are actualy there in the folder that you are trying to acces with the PHP script.  If they are then the path that is in the link is malformed.  Again, please post any error messages in their original state, it makes life much easier.

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247790
Share on other sites

hmm...change this code

$date = date("F d, Y"); // October 09, 2010
                  mysql_query("INSERT INTO videos VALUES ('', 'user_id', 'user_name', '$title', '$description', '$keywords', '$category', '$videoid', '0', '0', '$date')");
                  $query = mysql_query("SELECT * FROM videos WHERE user_id='id' AND title='$title' AND videoid='$videoid'");
                  $numrows = mysql_num_rows($query);
                  if ($numrows == 1){
                     $row = mysql_fetch_assoc($query);
                     $id = $row['id'];

to this code

$date = date("F d, Y"); // October 09, 2010
                  mysql_query("INSERT INTO videos VALUES ('', 'user_id', 'user_name', '$title', '$description', '$keywords', '$category', '$videoid', '0', '0', '$date')");
                  $query = mysql_query("SELECT videoid FROM videos WHERE user_id='id' AND title='$title' AND videoid='$videoid'");
                  $numrows = mysql_num_rows($query);
                  if ($numrows == 1){
                     $row = mysql_fetch_assoc($query);
                     $id = $row['videoid'];

 

and let me know what you get back.

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247794
Share on other sites

ok, there's a couple more things we need to look at:

1) this code is wrong

echo "Your video has been added. <a href='videos.php=$id'>Click here to view it.</a>";

I think you wanted it to be

echo "Your video has been added. <a href='videos.php?id=$id'>Click here to view it.</a>";

2) you are using a different format for object link link than the youtube link had:

object is using "'http://www.youtube.com/watch?v="

link is using " http://www.youtube.com/watch?v= "

 

are you linking the object wrong?

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247803
Share on other sites

this

 

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?id=$user_id'>$user_name</a></div>

<div style='float: right; font-size: 16px;'>$category</div>

<center>$views views</center>

</div>

</div>

</div>";

 

}

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247819
Share on other sites

yeah, well if you want to call a function of your own making you need to declare it first.  You might know that's what you want htmltext() to do, but PHP won't untill you tell it. That's not formated well enough to just drop it into a function, It wouldn't be of eny benifit.  What you would be as well doing is cuting this section of code and then pasting it over the line that is calling the htmltext()

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247828
Share on other sites

ok i fixed everything thanks but i have one more problem when i click my video on my video page it takes me to the page but doesnt show the video

 

 

// display title

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

 

// display video

echo "

<object width='640' height='505'>

<param name='movie' value='http://www.youtube.com/watch?v=".$videoid."&autoplay=1&hl=en_US&fs=1'></param>

<param name='allowFullScreen' value='true'></param>

<param name='allowscriptaccess' value='always'></param>

<embed src='http://www.youtube.com/watch?v=".$videoid."&autoplay=1&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";

Link to comment
https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247833
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.