June 27th, 2013, 03:57 PM
-
Set array in bind_result?
I know I've set variables directly this way to avoid the while() loop since there will only be 1 returned row, but my page now no seems to load. The server they want me to write this on appears to offer zero error anywhere I look. My best guess was just the setting array the way I am attempting to. Should this work?
PHP Code:
function setVars($machID) {
global $link;
$statement = $link->prepare("SELECT machines.`Part Description`,machines.`Part Number`,machines.`Serial Number`,machines.`Head Count`,machines.`Ink Type`,machines.`Software Version`,machines.`Spray Type`,machines.`HaspSerial`,machines.`HaspExp`,machines.`Date Opened`,machines.`Ship Date`,machines.`Installation Date`,machines.`End Warranty Period`,machines.`Note` FROM `machines` INNER JOIN `customers` ON machines.`CustomerID`=customers.`ID` WHERE machines.`ID`=?");
$statement->bind_param('i', $machID);
$statement->execute();
$statement->bind_result($var['desc'],$var['partNo'],$var['serialNo'],$var['headCount'],$var['inkType'],$var['softVer'],$var['sprayType'],$var['haspSerial'],$var['haspExp'],$var['opened'],$var['shipped'],$var['installed'],$var['EoW'],$var['notes']);
$statement->store_result();
$statement->fetch();
//while ($statement->fetch()) {
// $var['companyID'] = $col1;
// $var['name'] = $col2;
// $var['position'] = $col3;
// $var['number'] = $col4;
// $var['type'] = $col5;
// $var['email'] = $col6;
// $var['note'] = $col7;
//}
$statement->close();
return $var;
}