Mundo Posted February 23, 2009 Share Posted February 23, 2009 $query = mysql_query("INSERT INTO news ('news_ID', 'news_Title', 'news_Date', 'news_Entry', 'news_Picture') VALUES ('NULL', '$title', '$date', '$content', '$picture')"); Thats my query, it works because I can see it adding a row... But it's not inserting the data! <div id="entryheader"><span style="float: left;" id="entryheadertext"><strong><? echo "Hello $username, what would you like to do?"; ?></strong></span></div> <div id="entrybody"> <fieldset><legend><strong>Add New "NEWS"</strong></legend> <form action="index.php" method="post"> <div align="center"> Title: <input name="title" type="text" /> Date: <input name="date" type="text" value="<? $date = date("Y-m-d H:m:i"); echo $date; ?>" /><br /> <textarea name="content" value="content" cols="50" rows="12">Content...</textarea><br /> Picture: <input name="picture" value="picture" type="text" /><input type="submit" value="Go!" /> </div> </form> </fieldset> </div><br /> That is my form... And this is my file: <? session_start(); include "tpl/header.tpl"; include "tpl/navigation.tpl"; mysql_connect("localhost","root",""); mysql_select_db("ncfc"); $username = $_POST['username']; $password = $_POST['password']; $query = mysql_query("SELECT * from users WHERE user_UserName='$username' and user_Password='$password'"); $result = @mysql_fetch_array($query); if($result) { $_SESSION['auth'] = "TRUE"; } $_SESSION['adminmenu'] = $_GET['adminmenu']; if($_SESSION['adminmenu'] == "news" && $_SESSION['auth'] == "TRUE") { include "tpl/adminnews.tpl"; $news = $_POST["news"]; $date = $_POST['date']; $content = $_POST['content']; $picture = $_POST['picture']; $query = mysql_query("INSERT INTO news ('news_ID', 'news_Title', 'news_Date', 'news_Entry', 'news_Picture') VALUES ('NULL', '$title', '$date', '$content', '$picture')"); include "tpl/adminmenu.tpl"; } else if($_SESSION['adminmenu'] == "history" && $_SESSION['auth'] == "TRUE") { echo "HISTORY!!"; include "tpl/adminmenu.tpl"; } else if($_SESSION['adminmenu'] == "squad" && $_SESSION['auth'] == "TRUE") { echo "SQUAD!!"; include "tpl/adminmenu.tpl"; } else if($_SESSION['adminmenu'] == "results" && $_SESSION['auth'] == "TRUE") { echo "RESULTS!!"; include "tpl/adminmenu.tpl"; } else if($_SESSION['auth'] == "TRUE") { include "tpl/adminmenu.tpl"; } else { include "tpl/logon.tpl"; } include "tpl/footer.tpl"; mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/146446-help-with-mysql-query-insert-into/ Share on other sites More sharing options...
Mundo Posted February 23, 2009 Author Share Posted February 23, 2009 Anyone? mysql_query("INSERT INTO news (news_ID, news_Title, news_Date, news_Entry, news_Picture) VALUES ('NULL', '$_POST[title]', '$_POST[date]', '$_POST[content]', '$_POST[picture]')"); WILL NOT WORK mysql_query("INSERT INTO news (news_ID, news_Title, news_Date, news_Entry, news_Picture) VALUES ('NULL', 'Blah', 'Blah', 'Blah', 'BLAH')"); DOES WORK I've been fiddling for hours! Link to comment https://forums.phpfreaks.com/topic/146446-help-with-mysql-query-insert-into/#findComment-768869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.