PHP / SQL语法错误1064

I'm new to PHP so bear with me.

This is the code for entering into a bookings table on my site:

http://pastie.org/8190189

And this is the error I get when I enter data into a form on the front end of the site:

http://pastie.org/8190194

I've been working at it for hours but I can't get anywhere.

I thought the problem may be with the:

SELECT u_id FROM `joom_hl_puser_role` WHERE pid = '1'

The table puser_role just connects joomla users to hotels that they can manage on the site. (I want to enter the hotel manager's joomla user number to the table).

but I'm sure that the syntax is correct.

Thanks for your help.

The problem is your use of TIME();

TIME needs a parameter passed.

mysql> select TIME();
ERROR 1064 (42000): 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

Change it to

TIME(NOW())

From the MySQL manual for TIME

TIME(expr)

Extracts the time part of the time or datetime expression expr and returns it as a string.

This function is unsafe for statement-based replication. Beginning with MySQL 5.5.1, a warning is logged if you use this function when binlog_format is set to STATEMENT. (Bug #47995)

mysql> SELECT TIME('2003-12-31 01:02:03');
         -> '01:02:03' 

mysql> SELECT TIME('2003-12-31 01:02:03.000123');
         -> '01:02:03.000123'

you are in inserting the TIME() and NOW() functions inside "double quotes". try try chaing it to look like this

$query = "INSERT INTO `#__chbookings_bookings` (`id` ,`company` ,`firstname`,`lastname`, ,`email` ,`reference_number` , `transactionid` ,`invoice_number` ,    `property` ,`payment_type` ,`people` ,`phonenumber` ,`checkin_date` ,`checkout_date`,`room_type` , `status` , `total_amount` ,`amount_paid` ,`pending_amount`,    `date_booked`,`last_updated`, `comments`) VALUES (NULL , '".$user_id."','".$data['firstName']."', '".$data['lastName']."', 
'".$data['email']."', ".TIME().",
'".$result["transaction_id"]."','".$invoice_number."',
(SELECT u_id FROM `#__hl_puser_role` WHERE pid = '".$data['property_id']."'),
0 ,'".$total_adult."', '".$data['phone']."', 
'".$session->get('checkin_date')."', '".$session->get('checkout_date')."', 0, 0,
'".$final_amount."', '".$session->get('amount_payable')."', 
'".$session->get('balance_amount')."',
".NOW().", ".NOW().", 'comments'";