Hello Folks! New to Daniweb and programming in general! I've seen a couple other posts on this issue, but I wasn't able to sort it out with those suggestions. I'm getting the error mentioned in the subject, and I suspect it's something to do with my INSERTS/VALUES, but this is ancient code, and I'm only seeing it for the first time myself. Anyone have any suggestions for me? I've noticed I have quite a few more INSERTs than VALUES, and '$BOOTH' on line 45 looks suspect to me, but again, I'm very new and not certain. Thanks in advance!
#!/usr/local/bin/php
<?
$PageTitle = "CTS Room Input";
$SubHeader = "CTS Intranet";
$Style = "";
$Screens = $_POST['screens'];
$Boards = $_POST['boards'];
$Room = addslashes($_REQUEST['Room']);
?>
<?php require("../topper.php"); ?>
<div id="centerwrap">
<div id="content">
<!-- Begin Main Text of Page -->
<?PHP
$Booth = $_POST['Booth'];
if ($Booth == 'on')
{
$Booth = 1;
}
else
{
$Booth = 0;
}
$dbQuery = "INSERT INTO `MainDB` (`Campus`, `Building`, `Room`, `SeatingCap`,";
$dbQuery .= " `RoomType`, `FloorType`, `TeachingStation`, ";
$dbQuery .= " `Lighting`, `Windows`, `ProjectionBooth`,";
$dbQuery .= " `AdditionalInfo`, `Contact`, `Instructions`,";
$dbQuery .= " `AM1`, `AM2`, `AM5`, `AM6`, `AM7`, `AM12`, ";
$dbQuery .= " `AM13`, `AM14`, `AM16`, `AM17`, `AM18`, `AM19`, `AM20`, `AM21`, `AM22`, `AM23`)";
$dbQuery .= " VALUES ('" . $_POST['Campus'] . "', '" . $_POST['Building'] . "', '" . $_POST['RoomNumber'] . "', ";
$dbQuery .= "'" . $_POST['SeatingCap'] . "', ";
$dbQuery .= "'" . $_POST['RoomType'] . "', '" . $_POST['Floor'] . "',";
$dbQuery .= "'" . $_POST['TeachingStation'] . "', ";
$dbQuery .= "'" . $_POST['Lighting'] . "', '" . $_POST['Windows'] . "', ";
$dbQuery .= "'" . $Booth . "' ,'" . $_POST['Addinfo'] . "',";
$dbQuery .= "'" . $_POST['Contactinfo'] . "', '" . $_POST['Instructions'] . "'";
if ($Room != '')
{
$dbQuery = "UPDATE `MainDB` ";
$dbQuery .= "Set `Campus` = '" . $_POST['Campus'] . "', ";
$dbQuery .= "`Building` = '" . $_POST['Building'] . "', ";
$dbQuery .= "`Room` = '" . $_POST['RoomNumber'] . "', ";
$dbQuery .= "`SeatingCap` = '" . $_POST['SeatingCap'] . "', ";
$dbQuery .= "`RoomType` = '" . $_POST['RoomType'] . "', ";
$dbQuery .= "`FloorType` = '" . $_POST['Floor'] . "', ";
$dbQuery .= "`SeatingType` = '" . $_POST['SeatingType'] . "', ";
$dbQuery .= "`TeachingStation` = '" . $_POST['TeachingStation'] . "', ";
$dbQuery .= "`Lighting` = '" . $_POST['Lighting'] . "', ";
$dbQuery .= "`Windows` = '" . $_POST['Windows'] . "', ";
$dbQuery .= "`Wheelchair` = '" . $Wheelchair . "', ";
$dbQuery .= "`RegistarScheduled` = '" . $Registrar . "', ";
$dbQuery .= "`ProjectionBooth` = '" . $Booth . "', ";
$dbQuery .= "`AdditionalInfo` = '" . $_POST['Addinfo'] . "', ";
$dbQuery .= "`Contact` = '" . $_POST['Contactinfo'] . "', ";
$dbQuery .= "`Instructions` = '" . $_POST['Instructions'] . "' ";
}
$dbQuery2 = "Select AmenityID from AmenityDB Order by AmenityID";
$table2 = "Classroom";
require("../db2.php");
$lastID = mysql_insert_id();
while (mysql_Numrows($results2)>$y) //if there are records in the fields
{
$check="am" . mysql_result($results2,$y,"AmenityID"); //Find the amentities in the list.
// echo $check . "<br/>";
$Data = $_POST[$check];
if ($Data == 'on')
{
$Data = 1;
}
else
{
$Data = 0;
}
if ($Room != '')
{
$dbQuery .= ", `AM" . mysql_result($results2,$y,"AmenityID") . "` = '" . $Data . "' ";
}
else
{
$dbQuery .= ", '" . $Data . "'";
}
$y++;
}
if ($Room == '')
{
$dbQuery .= ")";
}
else
{
$dbQuery .= " where ID = '" . $Room . "'";
}
// echo $_POST['screens'];
// print $dbQuery . "<br />";
$table = "Classroom";
require("../db.php");
$lastID = mysql_insert_id();
if ($lastID == 0)
{
$lastID = $Room;
}
//----------------------------------------------------------------------------------------------------
if ($Room != '')
{
$dbQuery = "Delete FROM `AmenityMainLink` WHERE MainDBID = '" . $Room . "'";
$table = "Classroom";
require("../db.php");
}
$dbQuery = "Select AmenityID from AmenityDB Order by AmenityID";
$table = "Classroom";
require("../db.php");
while (mysql_Numrows($results)>$x)
{
$check="am" . mysql_result($results,$x,"AmenityID"); //Find the amentities in the list.
if ($_POST[$check]=="on")
{
$dbQuery2 = "INSERT INTO `AmenityMainLink` (`MainDBID`, `AmenityID`) Values (" . $lastID .", " . mysql_result($results,$x,"AmenityID") . ")";
$table2 = "Classroom";
require("../db2.php");
}
$x++;
}
//------------------------------------Boards-------------------------------------------------------------------
$x=0;
for ($i = 1; $i <= $_POST['boards']; $i++) {
$BLoc = "BoardLocal" . $i;
$BL = "BoardLength" . $i;
$BW = "BoardWidth" . $i;
$BC = "BoardColor" . $i;
if ($Room != '')
{
$dbQuery = "Delete FROM `ChalkboardDB` WHERE MainDBID = '" . $Room . "'";
$table = "Classroom";
require("../db.php");
}
if($BL!="")
{
$dbQuery3 = "INSERT INTO `ChalkboardDB` (`Height`, `Width`, `Position`, `MainDBID`, `ChalkType`) Values ('" . $_POST[$BL] . "', '" . $_POST[$BW] . "' , '" . $_POST[$BLoc] . "' ," . $lastID . ", '" . $_POST[$BC] . "')";
$table3 = "Classroom";
require("../db3.php");
}
}
for ($i = 1; $i <= $_POST['screens']; $i++) {
$PLoc = "ProjectLocal" . $i;
$PL = "ProjectLength" . $i;
$PW = "ProjectWidth" . $i;
$PT = "ProjectThrow" . $i;
$PD = "ProjectDDP" . $i;
$Ps = "Projectors" . $i;
$PLoc = $_POST[$PLoc];
$PL = $_POST[$PL];
$PW = $_POST[$PW];
$PT = $_POST[$PT];
$PD = $_POST[$PD];
$Ps = $_POST[$Ps];
if ($Ps = '')
{
$Ps = 0;
}
if ($PD == 'on')
{
$PD = 1;
}
else
{
$PD = 0;
}
$PE = "ProjectElec" . $i;
if ($PE == 'on')
{
$PE = 1;
}
else
{
$PE = 0;
}
$PC = "ProjectCSR" . $i;
if ($PC == 'on')
{
$PC = 1;
}
else
{
$PC = 0;
}
if ($Room != '')
{
$dbQuery = "Delete FROM `ProjectionScreenDB` WHERE MainDBID = '" . $Room . "'";
$table = "Classroom";
require("../db.php");
}
if ($PLoc != "")
{
$dbQuery = "INSERT INTO `ProjectionScreenDB` (`Height`, `Width`, `Location`, `MainDBID`, `Elec`, `CSR`, `DDP`, `Projectors`) Values ('" . $PL ."', '" . $PW ."', '" . $PLoc ."', '" . $lastID ."', '" . $PE ."', '" . $PC ."', '" . $PD ."', '" . $Ps ."')";
echo $dbQuery . "<br/><br/>";
$table = "Classroom";
require("../db.php");
}
}
?>
<!-- End Main Text of Page -->
The room has been added to the database. <a href='addition.php'>Enter another</a>
</div>
<!-- end content -->
<!--stopindex-->
<?php require("../footer.php"); ?>
</body>
</html>