SQL String Trouble
Posted: Mon Jul 10, 2006 2:19 pm
Here is the code I'm having trouble with:
What's happening here is that I get an error when I run this code saying that I'm giving an invalid argument to the second SQL string. The part of the string it doesn't like is "WHERE MachineServiceProfileID = $machineID" which leads me to believe that $machineID isn't being filled properly with $machineArray['MachineServiceProfileID']. Is it because I'm assigning the $machineID variable outside of the while loop where $machineArray[] is declared? Any help is appreciated!
Thanks in advance
Code: Select all
# Query the MachineServiceProfile for all machines for given company and put data into array
$machineQuery=odbc_exec($odbc, "SELECT * FROM MachineServiceProfiles Where CompanyID = $companyID ORDER BY DateMade ASC");
while ($machineInfo = odbc_fetch_array($machineQuery)){
# Load up the array
$tmpMachine = array('LocationID' => $machineInfo["LocationID"], 'MachineServiceProfileID' => $machineInfo["MachineServiceProfileID"], 'SerialNumber' => $machineInfo["SerialNumber"], 'Model' => $machineInfo["Model"], 'DateMade' => $machineInfo["DateMade"], 'ShippedDate' => $machineInfo["ShippedDate"], 'Notes' => $machineInfo["Notes"]);
$machineArray[] = $tmpMachine;
}
$machineID = $machineArray['MachineServiceProfileID'];
# THE SECOND STRING --
$machineNotesQuery=odbc_exec($odbc, "SELECT * FROM MachineServiceNotes Where MachineServiceProfileID = $machineID");
while ($machineNotes = odbc_fetch_array($machineNotesQuery)){
# Load up the array
$noteMachine = array('MachineServiceProfileID' => $machineNotes["MachineServiceProfileID"], 'DateCreated' => $machineNotes["DateCreated"], 'Notes' => $machineNotes["Notes"]);
$machineNotesArray[] = $noteMachine;
}Thanks in advance