ecabrera Posted August 3, 2011 Share Posted August 3, 2011 when i try to add a video to my website it says video not upload to database for somereason but i dont know were to fix it i look and look and cant find the problem i already have my tables create for adding videos help plz <?php $title = "Add Video"; ?> <?php require("styles/top.php"); ?> <div id='left'> <?php if ($username){ $categories = " <option value='Games'>Games</option> <option value='Music'>Music</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/connect.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"; } else echo "<h2><font color='red'>You must be logged in to add a video.</font></h2>"; ?> </div> <div id='right'></div> <?php require("styles/bottom.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/243740-help-mee-plz/ Share on other sites More sharing options...
Maq Posted August 3, 2011 Share Posted August 3, 2011 Check to make sure your INSERT isn't failing. Add or die(mysql_error()) on the end. Quote Link to comment https://forums.phpfreaks.com/topic/243740-help-mee-plz/#findComment-1251466 Share on other sites More sharing options...
ecabrera Posted August 3, 2011 Author Share Posted August 3, 2011 thanks dude i made a mistake on mysql_query("INSERT INTO videos VALUES ('', '$userid', '$username', '$title', '$description', '$keywords', '$category', '$videoid', '0', '0', '$date')"); i had to take out the extra '0' thanks for helping Quote Link to comment https://forums.phpfreaks.com/topic/243740-help-mee-plz/#findComment-1251472 Share on other sites More sharing options...
requinix Posted August 3, 2011 Share Posted August 3, 2011 For the love of God, learn how to use mysql_real_escape_string. Quote Link to comment https://forums.phpfreaks.com/topic/243740-help-mee-plz/#findComment-1251475 Share on other sites More sharing options...
Maq Posted August 4, 2011 Share Posted August 4, 2011 ecabrera, only use or die() for debugging. Handling errors/exceptions appropriately (without killing the script) is a good practice. Check this read out - http://www.phpfreaks.com/blog/or-die-must-die Quote Link to comment https://forums.phpfreaks.com/topic/243740-help-mee-plz/#findComment-1251921 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.