a1amattyj Posted February 11, 2008 Share Posted February 11, 2008 Hello, When someone fills in my form, its meant to record such variables into the database. Im just developing it but it wont inset them into the database and nor does it show any errors: <?php //Grab captcha from form and template header.. session_start(); include("header.php"); ?> <? //Grab the index form for report if(!$_GET){ include("form.php"); } ?> <? //Check for errors in form if($_GET['act']=='report'){ //Check security code is correct if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) { //Swap post's to variables.. $visitormail = $_POST['email']; $name = $_POST['name']; $forumname = $_POST['forumname']; $domain = $_POST['domain']; $type = $_POST['type']; $comment = $_POST['comment']; $sure = $_POST['sure']; $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $date = date("F j, Y, g:i a"); $a = 0; //Check fields arn't empty.. if(empty($visitormail) || empty($name) || empty($domain) || empty($forumname) || empty($type) || empty($sure) || empty($comment )) { echo "Please go back and fill in all fields\n"; $a = 1; } //Check the email is valid.. if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")) && $a==0) { echo "<h1>Error!</h1><p>Sorry, you did not enter a valid email. Go back a try again\n</p>"; $a = 1; } //If all is correct make database query if($a==0){ ?> <h1><center>Forum Reported..</center></h1> <p> <table width="300"><tr width="20"><td>Thanks for reporting, <span style="color:green; font-weight:bold"><? echo "$name"; ?></span>.</td></tr></table> <? //Grab mySQL Details include("config.php"); //Inset into the database mysql_query("INSERT INTO `easyfor1_reports`.`reports` (`forumname`, `name`, `email`, `type`, `ip`, `date`, `status`, `comments`) VALUES (\'$forumname\', \'$name\', \'$visitormail\', \'$type\', \'$ip\', \'$date\', \'Pending\', \'$comment\');'"); ?> <? } //Give errror if security code is incorrect unset($_SESSION['security_code']); } else { echo "Enter a valid captcha image please.."; } } ?> <? //Grab footer template include("footer.php"); ?> Thanks Quote Link to comment Share on other sites More sharing options...
revraz Posted February 11, 2008 Share Posted February 11, 2008 Use <?php instead of just <? Use mysql_error() after your query and it will show you the error. Remove all those slashes in your VALUES variables in your INSERT statement. Quote Link to comment Share on other sites More sharing options...
a1amattyj Posted February 11, 2008 Author Share Posted February 11, 2008 Use <?php instead of just <? Use mysql_error() after your query and it will show you the error. Remove all those slashes in your VALUES variables in your INSERT statement. Thanks, After submitted now i get this error: 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 ';'' at line 2 Quote Link to comment Share on other sites More sharing options...
revraz Posted February 11, 2008 Share Posted February 11, 2008 Looks like you have a stragler single quote left, maybe this one $comment);' <--- Repost just the query line. Quote Link to comment Share on other sites More sharing options...
a1amattyj Posted February 11, 2008 Author Share Posted February 11, 2008 Looks like you have a stragler single quote left, maybe this one $comment);' <--- Repost just the query line. Thanks alot, it works now. FROM : mysql_query("INSERT INTO `easyfor1_reports`.`reports` (`forumname`, `name`, `email`, `type`, `ip`, `date`, `status`, `comments`) VALUES ('$forumname', '$name', '$visitormail', '$type', '$ip', '$date', 'Pending', '$comment');'") or die(mysql_error()); TO mysql_query("INSERT INTO `easyfor1_reports`.`reports` (`forumname`, `name`, `email`, `type`, `ip`, `date`, `status`, `comments`) VALUES ('$forumname', '$name', '$visitormail', '$type', '$ip', '$date', 'Pending', '$comment')") or die(mysql_error()); Thanks alot. 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.