Jump to content

Not Inserting into DB?


Lamez

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.