I am kind of stuck. I keep getting a syntax error. Can anyone take a look and let me know whats going wrong?
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 'return (Badge, Dept, Asset) VALUES ('61584', 'IT', 12345)' at line 1
<?php
$dept = $_GET['dept'];
$badge = $_GET['badge'];
if (empty($badge)) {
echo '<center> You must insert a value into the Badge field </center>';
}
else {
foreach($_GET['asset'] as $key => $value) {
$db=mysql_connect ("localhost", "USER", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
$mydb=mysql_select_db("radios") or die ('I cannot select that table' . mysql_error());
# mysql_query("INSERT INTO return (Badge, Dept, Asset) VALUES (test, test, test)") or die ('Can not write to DB because: ' . mysql_error());
mysql_query("INSERT INTO return (Badge, Dept, Asset) VALUES ('$badge', '$dept', $value)") or die ('<body style="background-color:red">' . mysql_error());
echo $value;
echo '<br>';
}
echo '<body style="background-color:green">';
}
?>
<html>
<head>
<title>Radio return</title>
</head>
<body>
<form action="index.php" method="get" id="badgeform">
<center> Badge: <input type="text" name="badge" id="badgefield"/>
<script>document.getElementById('badgefield').focus()</script>
<center> Dept: <input type="text" name="dept" id="deptfield"/>
<center> Asset: <input type="text" name="asset[1]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[2]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[3]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[4]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[5]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[6]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[7]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[8]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[9]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[10]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[11]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[12]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[13]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[14]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[15]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[16]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[17]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[18]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[19]" id="assetfield"/>
<center> Asset: <input type="text" name="asset[20]" id="assetfield"/>
<input type="submit"> </center>
</form>
</body>
</html>