PHP and mysql booking with error "Unsupported operand types" -


i'm working on room booking succeeded number of rooms booked on particular dates. i'm having trouble subtracting number of rooms booked total rooms. keeps telling me '$no_of_rooms' array , i'm not able subtract total rooms. have error "fatal error: unsupported operand types...".

//getting number of rooms booked on particular dates $query = "select count(*)     reservation     (roomid = '$id' , (arrival <= '$check_out' , departure >= '$check_in'))";  $result = mysql_query($query);  if($result){     $no_of_rooms = mysql_fetch_assoc($result);     $freerooms = $total_rooms - $no_of_rooms; //-->error redirected here     var_dump($no_of_rooms);     var_dump($freerooms); } 

can guide me on this, i've started learning php. i've looked @ many threads type of error still nothing resembling mine.

$no_of_rooms is array: associative array, named keys corresponding column names. see php docs on mysql_fetch_assoc. you'll have extract number of rooms array, , can operations on it.

please note, mysql_fetch_assoc has been deprecated in php 5.5.0 in favor of other extensions pdo.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -