ecabrera Posted July 27, 2011 Share Posted July 27, 2011 hey im create a website where you can add videos and i created this script but i dont know whats wrong 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> Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/ Share on other sites More sharing options...
darkfreaks Posted July 27, 2011 Share Posted July 27, 2011 organize your code . look into some tutorials on switch statements. http://php.net/manual/en/control-structures.switch.php Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247726 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 still i dont gett it im new to php its Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247729 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 Can some one plz help me plz or can u correct it im just 16 but still learning plzz Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247736 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247755 Share on other sites More sharing options...
SpaceLama Posted July 27, 2011 Share Posted July 27, 2011 Only post the peace of code where the question is about. People aint gonna read all that just to help you. Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247759 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 well there might be nice people that would im just 16 im just learning Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247760 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 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){}. Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247773 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 ok thanks i like people like u that are willing to help 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 Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247777 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247785 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 thanks alot it works it doesnt give me a notice but now when i click on a video it still brings me to a not found page its says the requested url/videos was not found on this sever even though when i look at my db it shows videos Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247788 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247790 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 it doesnt give me any errors its just when i click it brings me to that page but maybe it has to do with this idk echo "Your video has been added. <a href='$site/videos?id=$id'>Click here to view it.</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247792 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247794 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 when i add that itand refresh my page my whole page was blank Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247795 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 which page goes blank? the one that displays the link or the one after you click on the link? Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247797 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 the one after i click the link Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247799 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247803 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 yes Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247808 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 ok i fixed it and it works but now it shows Fatal error: Call to undefined function htmltext() in /home/ecabrera/public_html/videos.php on line 48 $description = htmltext($description); Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247811 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 yeah, I have never heard of a PHP function called htmltext(). What are you trying to do to $description? Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247814 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 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>"; } Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247819 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 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() Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247828 Share on other sites More sharing options...
ecabrera Posted July 27, 2011 Author Share Posted July 27, 2011 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"; Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247833 Share on other sites More sharing options...
Muddy_Funster Posted July 27, 2011 Share Posted July 27, 2011 you just copied and pasted the original code, there are no signs of any of the changes that you should have done, please post up your updated code and make sure that all code you post goes inside php tags - makes it much easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/242917-helppppp-me/#findComment-1247835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.