Shiny_Charizard Posted February 3, 2008 Share Posted February 3, 2008 <?PHP include('top.php'); $ID = $_GET["ID"]; $username= $_SESSION['username']; //If User Is Not Logged In if(!isset($username)) { include('connect.php'); echo "<link rel='stylesheet' href='style.css' type='text/css'>"; echo "<center>"; echo "<table rules='rows' width='980px'>"; echo "<TR><TD CLASS='headings'> <a href='index.php'>Forum Index</a> --> <a href='index.php?forumID=$ID'>Viewing Topics</a> --> <a href='newtopic.php?ID=$ID'>Create New Topic</a></td></tr>"; echo "<tr><td class='theadings'>Error</td></tr>"; echo "<tr><td class='headings'><center>You are not logged in. You must be logged in to access the Forums.<BR> Click here to <a href='login.php'>Log in</a>.</center><td></tr>"; echo "</table>"; include('bottom.php'); exit; } include('connect.php'); echo "<link rel='stylesheet' href='style.css' type='text/css'>"; echo "<center>"; echo "<table rules='rows' width='980px'>"; echo "<TR><TD CLASS='headings'> <a href='index.php'>Forum Index</a> --> <a href='index.php?forumID=$ID'>Viewing Topics</a> --> <a href='newtopic.php?ID=$ID'>Create New Topic</a></td></tr>"; echo "<tr class='theadings'><td>Create a new topic</td></tr>"; echo "<tr class='headings'><td>"; if(isset($_POST['submit'])) { $name = $username; $post = $_POST['topic']; $subject = $_POST['subject']; if(strlen($post)<1) { echo "<center><font color='red'>Error:</font> You did not type in a post. Click here to go <a href='index.php'>back.</a></center>"; //user did not enter a post } else if(strlen($subject)<1) { echo "<center><font color='red'>Error:</font> You did not enter a Title. Click here to go <a href='index.php'>back.</a></center>"; //user did not enter a subject } else { $thedate=date("U"); $displaytime=date("F j, Y, g:i a"); $subject=strip_tags($subject); $post=strip_tags($post); $addpost =mysql_query("INSERT * INTO forum_posts ( author, title, post, showtime, realtime, lastposter, category_id ) VALUES ( '$name', '$subject', '$post', '$displaytime', '$thedate', '$name', '$ID' )") or die ("<center><font color='red'>Error:</font> Could not post topic. Click here to go <a href='index.php'>back.</a></center>"); echo "<center>Your topic has been created successfully! Click here to go <a href='index.php'>back.</a></center>"; } } else { echo "<center> <form name='new_topic' action='' method='POST'> Topic Title: <br /> <input type='text' name='subject' size='32'><br> Your post: <br /> <textarea name='topic' rows='5' cols='40'></textarea><br> <input type='submit' name='submit' value='Post New Topic'> </form> </center>"; } echo "</td></tr></table>"; echo "<table width='980'><tr><td class='headings'> HTML is <b>OFF</b><br> BBcode is <b>ON</b></td></tr></table>"; echo "</center>"; include('bottom.php'); ?> Why doesn't it insert the data to the MySQL table? I keep getting the error I made it say when it didn't insert the data. Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/ Share on other sites More sharing options...
pocobueno1388 Posted February 3, 2008 Share Posted February 3, 2008 Change your query to: $addpost =mysql_query("INSERT * INTO forum_posts ( author, title, post, showtime, realtime, lastposter, category_id ) VALUES ( '$name', '$subject', '$post', '$displaytime', '$thedate', '$name', '$ID' )") or die (mysql_error()); Post whatever error you get. Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/#findComment-456425 Share on other sites More sharing options...
Shiny_Charizard Posted February 3, 2008 Author Share Posted February 3, 2008 This is the error I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* INTO forum_posts ( author, title, post, showtime, realtime, lastpo' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/#findComment-456431 Share on other sites More sharing options...
pocobueno1388 Posted February 3, 2008 Share Posted February 3, 2008 Okay...do this and post what it gives you $addpost ="INSERT * INTO forum_posts ( author, title, post, showtime, realtime, lastposter, category_id ) VALUES ( '$name', '$subject', '$post', '$displaytime', '$thedate', '$name', '$ID' )"; $result = mysql_query($addpost)or die(mysql_error() . "<p>With Query<br>$addpost"); Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/#findComment-456463 Share on other sites More sharing options...
Shiny_Charizard Posted February 3, 2008 Author Share Posted February 3, 2008 This is what I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* INTO forum_posts ( author, title, post, showtime, realtime, lastpo' at line 1 With Query INSERT * INTO forum_posts ( author, title, post, showtime, realtime, lastposter, category_id ) VALUES ( 'Shiny_Charizard', 'Test', 'Test..', 'February 2, 2008, 9:34 pm', '1202006042', 'Shiny_Charizard', '1' ) Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/#findComment-456487 Share on other sites More sharing options...
pocobueno1388 Posted February 3, 2008 Share Posted February 3, 2008 Ah, I can't believe I didn't see it before. You need to take the '*' out. Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/#findComment-456503 Share on other sites More sharing options...
Shiny_Charizard Posted February 3, 2008 Author Share Posted February 3, 2008 Thanks a bunch pocobueno! Quote Link to comment https://forums.phpfreaks.com/topic/89118-solved-why-wont-it-insert-the-mysql-data/#findComment-456507 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.