I definitely agree with taquito. At no point in your posted code to you declare $dbc. Furthermore if it is in fact declared, and you just excluded that part, in the global scope outside of the function, you never pass it to the function or declare it as global in the function so that it is accessible. Basically if you declare $dbc prior to calling the stuff function (which you may), you would likely want to add a second parameter to the stuff function for the database connection, and call it $dbc.
function stuff ($cost, $dbc) {
..... code .....
}
or you could (this is bad practice thought
function stuff($cost) {
global $dbc;
........ code .......
}
chris.