conan318 Posted August 7, 2011 Share Posted August 7, 2011 <form method="post" action="lastride.php" enctype="multipart/form-data"> <h2>Last ride report<h2> <textarea name="last" rows="10" cols="100"> Add your last ride report here </textarea> <?php mysql_connect("localhost", "", "")or die("cannot connect"); mysql_select_db("main")or die("cannot select DB"); $data=$_POST['last']; $data = mysql_real_escape_string($data); $mk=date("Y/m/d"); $insert_nextride=mysql_query("INSERT INTO main.last (id,ridereport,date) VALUES ('','$data','$mk')"); if($insert_nextride) { echo "Next Ride updated"; header("location:mb-admin.html"); die();} else { echo "error in registration".mysql_error(); } ?> ridereport not inserting data into the database but the date is. thinking its something to do with that data not being passed from the from. had it working yesterday and now its broken lol Quote Link to comment https://forums.phpfreaks.com/topic/244084-not-inserting-into-database/ Share on other sites More sharing options...
AyKay47 Posted August 7, 2011 Share Posted August 7, 2011 do you not have a form submit button? you will want to check if the form has been passed before you execute the insertion code, also you cannot output data before calling the header() function <?php mysql_connect("localhost", "", "")or die("cannot connect"); mysql_select_db("main")or die("cannot select DB"); $data=$_POST['last']; if(!empty($data){ $mk=date("Y/m/d"); $data = mysql_real_escape_string($data); $insert_nextride=mysql_query("INSERT INTO last (id,ridereport,date) VALUES ('','$data','$mk')"); if($insert_nextride){ header("location:mb-admin.html"); exit; } else { echo "error in registration".mysql_error(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/244084-not-inserting-into-database/#findComment-1253556 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.