Error #1093 you-cant-specify-target-table-table-name-for-update-in-from-clause
I do not like the method provided in the linked question, due to the way UPDATE is processed in MySQL.

Especially in your case, where you want to allow (or restrict) the update based on values from several rows of the table (and not just the row to be updated), I suggest you use 2 statements, one to get the max and sum values from the tickettypes, events and ticketsorders tables and then update accordingly or use JOIN if you want to do this in one statement. The CROSS JOIN are not a problem here as the three first subqueries produce one row each: 

UPDATE 
    ( SELECT maxtickets 
      FROM tickettypes 
      WHERE id = $tickettype-&gt;id
    ) AS tt
  CROSS JOIN 
    ( SELECT maxtickets 
      FROM events 
      WHERE id = $eventid
    ) AS ev
  CROSS JOIN
    ( SELECT COALESCE(SUM(amount), 0) AS sum_amount
      FROM ticketsorders 
      WHERE tickettype_id = $tickettype-&gt;id
    ) AS ts
  JOIN
    ticketsorders AS t
      ON  ts.sum_amount +$val &lt;= tt.maxtickets
      AND ts.sum_amount +$val &lt;= ev.maxtickets  
SET 
    t.amount = $val 
WHERE 
    t.id = $ticketsorder-&gt;id ;