Try like this instead:
INSERT INTO connections (`c_id`,`in`,`out`,`ip`,`userID`)
VALUES (
(
SELECT p.c_id
FROM (select * from connections) p
WHERE (a bunch of conditions)
ORDER BY p.c_id DESC LIMIT 1
),
'1373799802',
0,
INET_ATON('127.0.0.1'),
4
)
ON DUPLICATE KEY UPDATE `out` = 1
This issue seems due to a bug in mysql version 4.1.7 which states that
you can't update the same table which you use in the SELECT part
see Here
Not sure if this is the same version you are using as well.