Nina555 Posted November 2, 2012 Share Posted November 2, 2012 (edited) Hi, I am newbie in PHP and I got some script which I just can't get to insert title in database. I would be very thankful if you could help me with this. Here is the code. I hope that trg86 doesn't mind I got in his topic. $surl = $_SERVER['HTTP_HOST'] ; if (strip_tags($_POST['add'])){ $vidid=mysql_real_escape_string(strip_tags($_POST['vidid'])); $url = "$vidid"; parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars); $t1=mysql_real_escape_string(strip_tags($_POST['tit1'])); $title="$t1"; parse_str( $title, $my_vars ); mysql_query("INSERT INTO `videos` (`id`, `videoid`, `views`, `title`) VALUES ('', '".$my_array_of_vars['v']."', '0', '".$my_vars['v']."');") or die (mysql_error()); $message="<img src=\"../img/tick-icon.jpg\">"; } if (strip_tags($_POST['rem'])){ $vidid2=mysql_real_escape_string(strip_tags($_POST['vidid2'])); $url = "$vidid2"; parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars ); mysql_query("DELETE FROM videos WHERE id=".$my_array_of_vars['v'].""); $message2="<img src=\"../img/tick-icon.jpg\">"; } ?><head> <html xmlns:fb="http://ogp.me/ns/fb#"> <title>Admin Panel</title> <META name="robots" content="NOINDEX,NOFOLLOW" /> <link type="text/css" rel="stylesheet" href="../css/admin.css" /> <link href="../img/favicon.ico" rel="icon" type="image/x-icon" /> <body> <a href="index.php"><img src="../img/logo.png" border="0"></a> <div class="banner"><a href="index.php">Delete</a> - <a href="add.php">Add & Remove</a> - <a href="logout.php">Logout</a></div> <div align="center"><form id="form1" method="post" action=""> Youtube URL: <input type="text" name="vidid" id="vidid"> Title: <input type="text" name="tit1" id="tit1"> <input name='add' type='submit' id='add' value='Add Video' /> <? echo"$message";?><br><br> Website URL: <input type="text" name="vidid2" id="vidid2"> <input name='rem' type='submit' id='rem' value='Remove Video' /> <? echo"$message2";?><br><br> Example: <strong>http://<? echo"$surl"; ?>/watch.php?v=25</strong> </div> </form> </body> Edited November 2, 2012 by Nina555 Quote Link to comment Share on other sites More sharing options...
MDCode Posted November 2, 2012 Share Posted November 2, 2012 (edited) Any errors? Edited November 2, 2012 by ExtremeGaming Quote Link to comment Share on other sites More sharing options...
Nina555 Posted November 2, 2012 Author Share Posted November 2, 2012 No there are no errors it just doesn't insert 'title' into database Quote Link to comment Share on other sites More sharing options...
MDCode Posted November 2, 2012 Share Posted November 2, 2012 Where is $my_vars Quote Link to comment Share on other sites More sharing options...
Nina555 Posted November 2, 2012 Author Share Posted November 2, 2012 If you mean where is defined it's not defined neither $my_array_of_vars and that part works. P.S I am newbie in php -.- Quote Link to comment Share on other sites More sharing options...
MDCode Posted November 2, 2012 Share Posted November 2, 2012 If they're not defined where do you expect to get the information from... Quote Link to comment Share on other sites More sharing options...
Nina555 Posted November 2, 2012 Author Share Posted November 2, 2012 It should get information from form, and as you can see $my_array_of_vars is not defined too and that part add video works fine Quote Link to comment Share on other sites More sharing options...
Nina555 Posted November 2, 2012 Author Share Posted November 2, 2012 $vi=mysql_query("SELECT * FROM videos WHERE id='$getid' LIMIT 1"); $v = mysql_fetch_object($vi); Quote Link to comment Share on other sites More sharing options...
Nina555 Posted November 2, 2012 Author Share Posted November 2, 2012 Thank you, your question inspired me and i have fixed the problem Quote Link to comment 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.