Auction function for a game
Use placeholder there: WHERE ha.house_id = $id"; Placeholder is better due to security approach.



if (count($_POST) &gt; 0) {

$limit = trim($_POST['limit']);
$char = trim($_POST['character']);


You should separate presentation from your logic. It will be better: read all $_POST outside the function and pass in arguments. Maybe you wanna later to play your game via AJAX, or something else, and you won't need $_POST anymore, but you still need the logic.

Due the same approach, returning status and errors from function is a better way, then just prints them out. You can return 2 values from function -- status and errors array.

Then do something like this:

list($status, $errors) = your_function(...);
if (!$status) {
    //printing errors
}


Or you can just return an array, and check length of it. If array contain some errors, print them out.



Rename your variables.

char to character

pid to playerId

limit2 to newLimit? Or what it means?

In your code it isn't clear enough. Especially limit2.