Just reading it these things look wrong. I don't know if any of these are the problem because you never said what happens when you run it.
You are going to execute the SELECT every time, that might be okay.
You are only keeping $content from the last row returned, all the others are ignored. That might be okay but there are more efficient ways to do it.
You connect a second time inside the $action==update. Probably won't hurt, but you should quote "update".
I don't see where $table_name or $text are set, maybe from the form, can't tell.
You don't need to escape the single quotes in VALUES (\'$text\') That might be where its really failing, although Craig is right, remove the @ so php can report the problem and put them back in when everything works.
I wouldn't really call this an update, you SELECT and INSERT, but UPDATE is something different.