mattd8752 Posted February 10, 2007 Share Posted February 10, 2007 This outputs "Successful" everytime, but nothing is put into MySQL. The database setup is working since my other pages work. <?php include "./includes/dbconnect.php"; if(isset($_POST['Post'])){ $errors = 0; if(!isset($_POST['title'])){ $errors++; } if(!isset($_POST['message'])){ $errors++; } if(!isset($_POST['forumid'])){ $errors++; } if(!isset($_POST['type'])){ $error++; }else{ if($_POST['type'] != "new" && $_POST['type'] != "reply"){ $errors++; } } if($errors == 0){ $query = "INSERT INTO topic VALUES ('2','".$_POST['forumid']."','".$_POST['title']."','".$_POST['message']."','Guest','N/A','N/A','0','0')"; if(!$query){ echo "Error, ".mysql_error(); }else{ echo "Successful".mysql_error(); } } } if($errors != 0 || !isset($_POST['Post'])){ ?> <h1>Post a New Topic/Reply</h1> <br> <?php if($errors != 0){ echo "There were " . $errors . " errors. Please make sure all fields are filled."; } ?> <form method="POST" action="post.php"> Title: <input type="text" name="title" size="20"><br><br><br> Message:<br> <textarea rows="10" name="message" cols="72"></textarea><br> <input type="hidden" name="forumid" value="1"> <input type="hidden" name="type" value="new"> <input type="submit" value="Post" name="Post"> </form> <?php } include "footer.php"; ?> Link to comment https://forums.phpfreaks.com/topic/37897-mysql-not-working/ Share on other sites More sharing options...
papaface Posted February 10, 2007 Share Posted February 10, 2007 Your not querying the SQL. $query = "INSERT INTO topic VALUES ('2 should be: $query = mysql_query("INSERT INTO topic VALUES ('2 Link to comment https://forums.phpfreaks.com/topic/37897-mysql-not-working/#findComment-181415 Share on other sites More sharing options...
JJohnsenDK Posted February 10, 2007 Share Posted February 10, 2007 You have fotgotten mysql_query if($errors == 0){ $query = mysql_quey("INSERT INTO topic VALUES ('2','".$_POST['forumid']."','".$_POST['title']."','".$_POST['message']."','Guest','N/A','N/A','0','0')"); if(!$query){ echo "Error, ".mysql_error(); }else{ echo "Successful".mysql_error(); } } Link to comment https://forums.phpfreaks.com/topic/37897-mysql-not-working/#findComment-181417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.