UPDATE
Может быть, я просто дурачок и не вижу своей ошибки. По сути, эта функция обрабатывает математику за всем остальным. Он имеет несколько запросов и обновлений и вставляет в две разные таблицы ..
Когда я пытаюсь обработать его, он дает мне:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/53/7311353/html/gs/cca/accounts/include/processAct.php on line 241
Вот моя функция:
function calculateBilling(){
$date = date('mdY');
$bid = mysql_real_escape_string($_POST['bid']);
$account = mysql_real_escape_string($_POST['account']);
$timein = mysql_real_escape_string($_POST['timein']);
$desc = mysql_real_escape_string($_POST['desc']);
$hrs2calc1 = mysql_real_escape_string($_POST['hrly']);
$hrs2calc2 = mysql_real_escape_string($_POST['rhrly']);
$query = 'SELECT bid, account, hrly, rhrly, bal FROM billing WHERE bid='.$bid;
$result = mysql_query($query);
HERES LINE 241 ----> while($row = mysql_fetch_row($result)){
$accounttobebilled = $row[1];
$hrly = $row[2];
$rhrly = $row[3];
$curbal = $row[4];
}
$sub1 = $hrly * $hrs2calc1;
$sub2 = $rhrly * $hrs2calc2;
$subtotal = $sub1 + $sub2;
$total = $curbal + $subtotal;
$query2 = 'UPDATE billing SET bal = '.$total.' WHERE bid ='.$bid;
$result2 = mysql_query($query2);
// Update Billing Log for this customer
mysql_query("INSERT INTO billingLog (bid, date, hrsOnsite, hrsRemote, timein, descript, total) VALUES ('$bid', '$date', '$hrs2calc1', '$hrs2calc2', '$timein', '$desc', '$subtotal')");
}
Я думаю, что проблема связана с моим выбором (раскрывающимся списком), где он публикует скрипт:
<select class="form-dropdown validate[required]" style="width:150px" id="input_5" name="account">
<?php
while($row =
mysql_fetch_row($result)){
$bid =$row[0];
$account = $row[1];
echo '<option value="'.$bid.'">'.$account.'</option>';
}
?>
</select>
Для Джеймса:
SELECT bid, account, hrly, rhrly, bal FROM billing WHERE bid=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 '' at line 1
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/53/7311353/html/gs/cca/accounts/include/processAct.php on line 243
UPDATE billing SET bal = 0 WHERE bid =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 '' at line 1INSERT INTO billingLog (bid, date, hrsOnsite, hrsRemote, timein, descript, total) VALUES ('', '07292011', '2', '2', '2', '2', '0')