Twixmafia Posted June 16, 2013 Share Posted June 16, 2013 hi i've made this code - but it won't post anything to mysql and i do not get any error codes. What have i done wrong? <?php include 'dbconnect.php'; @$a=$_POST['Q1']; if(@$_POST['submit']){ $s = mysql_query("INSERT INTO `test`.`valg`(`Person`, `score_kat_1`) VALUES (NULL, '$a')"); echo "Your Data Inserted"; mysql_query($s); } ?> <form method="post"> <div id="boxbodytext-test"> Spørgsmål 1 <div id="boxbodytext-svar"> <input type="radio" name="Q1" value="1"/>yes <input type="radio" name="Q1" value="0"/>no </div> </div> <input type="submit" name="submit" value="Submit"/> </form> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 16, 2013 Share Posted June 16, 2013 Why aren't you checking for the success of your query?? Might tell you that you have a problem with your query statement. What's a "valg"?? Don't know what you are attempting, but your query definitely looks bad. Quote Link to comment Share on other sites More sharing options...
Solution Twixmafia Posted June 16, 2013 Author Solution Share Posted June 16, 2013 (edited) i've tried to insert this in mySQL - and it works: INSERT INTO `test`.`valg`(`Person`, `score_kat_1`) VALUES (NULL, '$a') "test" is the database and "valg" is the table. (The reason it looks this bad is because i made phpmyadmin make the PHP code for me) i've found a way to make it work. Just to sum up: appendix.php ... <?php include 'dbconnect.php'; @$a=$_POST['Q1']; ?> <form method="post" action="add-to-db.php"> <div id="boxbodytext-test"> Spørgsmål 1 <div id="boxbodytext-svar"> <input type="radio" name="Q1" value="1"/>yes <input type="radio" name="Q1" value="0"/>no </div> </div> <input type="submit" name="submit" value="Submit"/> </form> ... add-to-db.php <?php require_once 'dbconnect.php'; require_once 'appendix.php'; $sql = "INSERT INTO `test`.`valg` (`Person`, `score_kat_1`) VALUES (NULL, '$a');"; header("Location: test3.php"); mysql_query($sql, $conn); ?> Edited June 16, 2013 by Twixmafia 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.