supanoob Posted July 17, 2006 Share Posted July 17, 2006 well, i have the following code and for some reason it doesnt insert into the DB nothing happens nothing gets inserted[code]session_start();require_once('dbconnect2.php');$ip=($_SERVER['REMOTE_ADDR']);$T1=$_POST['T1'];$D1=$_POST['D1'];$D2=$_POST['D2'];$D3=$_POST['D3'];$D4=$_POST['D4'];$D5=$_POST['D5'];$D6=$_POST['D6'];$D7=$_POST['D7'];$D8=$_POST['D8'];$D9=$_POST['D9'];$D10=$_POST['D10'];$T1=trim($T1);$D1=trim($D1);$D2=trim($D2);$D3=trim($D3);$D4=trim($D4);$D5=trim($D5);$D6=trim($D6);$D7=trim($D7);$D8=trim($D8);$D9=trim($D9);$D10=trim($D10);$query="insert into `match` (name, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) values ('$T1', '$D1', '$D2', '$D3', '$D4', '$D5', '$D6', '$D7', '$D8', '$D9', '$D10')";$result=mysql_query($query);echo "You have added your name and answers to our Database. We will be in touch within the week.";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/ Share on other sites More sharing options...
Kurt Posted July 17, 2006 Share Posted July 17, 2006 Try changing:$result=mysql_query($query);to:$result=mysql_query($query) or die(mysql_error());to see what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59486 Share on other sites More sharing options...
supanoob Posted July 17, 2006 Author Share Posted July 17, 2006 i dont get an error it says it has submitted ok :S Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59492 Share on other sites More sharing options...
SammyP Posted July 17, 2006 Share Posted July 17, 2006 Have you checked mysql_affected_rows to see if it thinks a record has been inserted? If there is no error then it probably does. Which I'd suggest might mean the record is being inserted. I assume you've checked the number of records to ensure it isn't actually going in.If all of that is fruitless then you have a ponderer in my opinion.Sam. Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59496 Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 session_start();require_once('dbconnect2.php');$ip=($_SERVER['REMOTE_ADDR']);$T1=$_POST['T1'];$D1=$_POST['D1'];$D2=$_POST['D2'];$D3=$_POST['D3'];$D4=$_POST['D4'];$D5=$_POST['D5'];$D6=$_POST['D6'];$D7=$_POST['D7'];$D8=$_POST['D8'];$D9=$_POST['D9'];$D10=$_POST['D10'];$T1=trim($T1);$D1=trim($D1);$D2=trim($D2);$D3=trim($D3);$D4=trim($D4);$D5=trim($D5);$D6=trim($D6);$D7=trim($D7);$D8=trim($D8);$D9=trim($D9);$D10=trim($D10);if($_POST['submit']){$query="insert into `match` (name, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) values ('$T1', '$D1', '$D2', '$D3', '$D4', '$D5', '$D6', '$D7', '$D8', '$D9', '$D10')";$result=mysql_query($query);echo "You have added your name and answers to our Database. We will be in touch within the week.";} Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59507 Share on other sites More sharing options...
SammyP Posted July 17, 2006 Share Posted July 17, 2006 I can't see what the previous post is on about (maybe it isn't finished) but I also should have mentioned that it is always worth echoing the SQL statement to yourself if it doesn't work, and then try applying it directly to the database rather than through PHP. Might get you some more clues.Sam. Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59514 Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 give the insert a condition what ever you have named the form ok.if($POST['submit']){insert} Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59517 Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 Post your database information so we can have a proper look ok. Quote Link to comment https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59520 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.