Lamez Posted January 25, 2008 Share Posted January 25, 2008 I cannot get my fields to insert into the database, will someone check my code, and tell me if I have any mistakes? <?php /*Connect, and define user*/ include ("../../style/include/session.php"); /*Define Variables*/ $region = $_POST['region1']; $a1 = $_POST['1a']; $a2 = $_POST['2a']; $a3 = $_POST['3a']; $a4 = $_POST['4a']; $a5 = $_POST['5a']; $a6 = $_POST['6a']; $a7 = $_POST['7a']; $a8 = $_POST['8a']; $a9 = $_POST['9a']; $a10 = $_POST['10a']; $a11 = $_POST['11a']; $a12 = $_POST['12a']; $a13 = $_POST['13a']; $a14 = $_POST['14a']; $a15 = $_POST['15a']; $a16 = $_POST['16a']; /*Add to DB*/ mysql_query("INSERT INTO `1` (region, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) VALUES ('$region', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10', '$a11', '$a12', '$a13', '$a14', '$a15, '$a16')"); echo $region; ?> Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/ Share on other sites More sharing options...
Lamez Posted January 25, 2008 Author Share Posted January 25, 2008 anyone, I did not think it would be that hard?? Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448630 Share on other sites More sharing options...
tapos Posted January 25, 2008 Share Posted January 25, 2008 What is the error?? can u post?? Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448634 Share on other sites More sharing options...
Lamez Posted January 25, 2008 Author Share Posted January 25, 2008 there is no error, it is just not adding the submitted fields to the database. Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448636 Share on other sites More sharing options...
sstangle73 Posted January 25, 2008 Share Posted January 25, 2008 any errors or it just doesnt? try this: <?php /*Connect, and define user*/ include ("../../style/include/session.php"); error_reporting(E_ALL); /*Define Variables*/ $region = $_POST['region1']; $a1 = $_POST['1a']; $a2 = $_POST['2a']; $a3 = $_POST['3a']; $a4 = $_POST['4a']; $a5 = $_POST['5a']; $a6 = $_POST['6a']; $a7 = $_POST['7a']; $a8 = $_POST['8a']; $a9 = $_POST['9a']; $a10 = $_POST['10a']; $a11 = $_POST['11a']; $a12 = $_POST['12a']; $a13 = $_POST['13a']; $a14 = $_POST['14a']; $a15 = $_POST['15a']; $a16 = $_POST['16a']; /*Add to DB*/ function add($region, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16){ $q = "INSERT INTO abn VALUES ('$region', '$a1', '$a2', '$a3', '$a4', '$a5', '$a6', '$a7', '$a8', '$a9', '$a10', '$a11', '$a12', '$a13', '$a14', '$a15, '$a16')"; if ($result = mysql_query($q)) { return $result; } else { die(mysql_error() . "<br />" . $q); } } add($region, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $a10, $a11, $a12, $a13, $a14, $a15, $a16); echo $region; ?> Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448637 Share on other sites More sharing options...
Lamez Posted January 25, 2008 Author Share Posted January 25, 2008 alright, I get this error now: 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 'Test')' at line 1 INSERT INTO abn VALUES ('Test', 'Test', 'asdfas', 'TestTestf', 'Testv', 'sdfasdf', 'df', 'sdfasd', 'adf', 'adf', 'Testf', 'Test', 'sdf', 'Test', 'asdfasd', 'Test, 'Test') Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448651 Share on other sites More sharing options...
sstangle73 Posted January 25, 2008 Share Posted January 25, 2008 im assumeing your tables are set up correctly right>? also change the table on the code i gave you from abn to what ever i use i forgot sorry. Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448884 Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 You forgot a ' here '$a15' <---- Link to comment https://forums.phpfreaks.com/topic/87705-not-inserting-into-db/#findComment-448888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.